diff --git a/NumberSearch.DataAccess/Models/PurchasedPhoneNumber.cs b/NumberSearch.DataAccess/Models/PurchasedPhoneNumber.cs index 1d871f6d..acd0831c 100644 --- a/NumberSearch.DataAccess/Models/PurchasedPhoneNumber.cs +++ b/NumberSearch.DataAccess/Models/PurchasedPhoneNumber.cs @@ -72,7 +72,7 @@ public static async Task> GetByOrderIdAsync(Gu /// /// /// - public static async Task GetByDialedNumberAsync(string dialedNumber, string connectionString) + public static async Task GetByDialedNumberAsync(string dialedNumber, string connectionString) { await using var connection = new NpgsqlConnection(connectionString); diff --git a/NumberSearch.Ingest/Owned.cs b/NumberSearch.Ingest/Owned.cs index dccdf5c3..abd3bee4 100644 --- a/NumberSearch.Ingest/Owned.cs +++ b/NumberSearch.Ingest/Owned.cs @@ -152,7 +152,10 @@ public async static Task IngestAsync(IngestConfiguration confi // Remove the lock from the database to prevent it from getting cluttered with blank entries. var lockEntry = await IngestStatistics.GetLockAsync("OwnedNumbers", configuration.Postgresql).ConfigureAwait(false); - _ = await lockEntry.DeleteAsync(configuration.Postgresql).ConfigureAwait(false); + if (lockEntry is not null) + { + _ = await lockEntry.DeleteAsync(configuration.Postgresql).ConfigureAwait(false); + } // Remove all of the old numbers from the database. Log.Information("[OwnedNumbers] Marking numbers that failed to reingest as inactive in the database."); diff --git a/NumberSearch.Ingest/Provider.cs b/NumberSearch.Ingest/Provider.cs index c0d1c9bb..63bf7ff1 100644 --- a/NumberSearch.Ingest/Provider.cs +++ b/NumberSearch.Ingest/Provider.cs @@ -103,8 +103,7 @@ public static async Task BulkVSDailyAsync(IngestConfiguration UpdatedExisting = 0, Lock = true }; - - var checkLock = await lockingStats.PostAsync(appConfig.Postgresql).ConfigureAwait(false); + _ = await lockingStats.PostAsync(appConfig.Postgresql).ConfigureAwait(false); // Ingest all available phones numbers from the BulkVs API. Log.Information("Ingesting data from BulkVS"); @@ -112,7 +111,10 @@ public static async Task BulkVSDailyAsync(IngestConfiguration // Remove the lock from the database to prevent it from getting cluttered with blank entries. var lockEntry = await IngestStatistics.GetLockAsync("BulkVS", appConfig.Postgresql).ConfigureAwait(false); - var checkRemoveLock = await lockEntry.DeleteAsync(appConfig.Postgresql).ConfigureAwait(false); + if (lockEntry is not null) + { + _ = await lockEntry.DeleteAsync(appConfig.Postgresql).ConfigureAwait(false); + } // Remove all of the old numbers from the database. Log.Information("[BulkVS] Removing old numbers from the database."); @@ -254,7 +256,7 @@ public static async Task FirstPointComDailyAsync(IngestConfigu Lock = true }; - var checkLock = await lockingStats.PostAsync(appConfig.Postgresql).ConfigureAwait(false); + _ = await lockingStats.PostAsync(appConfig.Postgresql).ConfigureAwait(false); // Ingest all available numbers in the FirsPointCom API. Log.Information("[FirstPointCom] Ingesting data from FirstPointCom"); @@ -262,7 +264,10 @@ public static async Task FirstPointComDailyAsync(IngestConfigu // Remove the lock from the database to prevent it from getting cluttered with blank entries. var lockEntry = await IngestStatistics.GetLockAsync("FirstPointCom", appConfig.Postgresql).ConfigureAwait(false); - var checkRemoveLock = await lockEntry.DeleteAsync(appConfig.Postgresql).ConfigureAwait(false); + if (lockEntry is not null) + { + _ = await lockEntry.DeleteAsync(appConfig.Postgresql).ConfigureAwait(false); + } // Remove all of the old numbers from the database. Log.Information("[FirstPointCom] Removing old FirstPointCom numbers from the database."); diff --git a/NumberSearch.Mvc/Controllers/CartController.cs b/NumberSearch.Mvc/Controllers/CartController.cs index 919e2878..6399245a 100644 --- a/NumberSearch.Mvc/Controllers/CartController.cs +++ b/NumberSearch.Mvc/Controllers/CartController.cs @@ -13,8 +13,6 @@ using NumberSearch.DataAccess.InvoiceNinja; using NumberSearch.Mvc.Models; -using Org.BouncyCastle.Bcpg.Sig; - using Serilog; using System; @@ -28,22 +26,12 @@ namespace NumberSearch.Mvc.Controllers { [ApiExplorerSettings(IgnoreApi = true)] - public class CartController : Controller + public class CartController(MvcConfiguration mvcConfiguration) : Controller { - private readonly string _postgresql; - private readonly string _invoiceNinjaToken; - private readonly string _emailOrders; - private readonly string _emailSupport; - private readonly MvcConfiguration _configuration; - - public CartController(MvcConfiguration mvcConfiguration) - { - _postgresql = mvcConfiguration.PostgresqlProd; - _invoiceNinjaToken = mvcConfiguration.InvoiceNinjaToken; - _emailOrders = mvcConfiguration.EmailOrders; - _emailSupport = mvcConfiguration.EmailSupport; - _configuration = mvcConfiguration; - } + private readonly string _postgresql = mvcConfiguration.PostgresqlProd; + private readonly string _invoiceNinjaToken = mvcConfiguration.InvoiceNinjaToken; + private readonly string _emailOrders = mvcConfiguration.EmailOrders; + private readonly MvcConfiguration _configuration = mvcConfiguration; [HttpGet] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] @@ -153,7 +141,7 @@ public async Task CheckoutAsync() await HttpContext.Session.LoadAsync().ConfigureAwait(false); var cart = Cart.GetFromSession(HttpContext.Session); - if (cart is not null && cart.ProductOrders is not null && !cart.ProductOrders.Any()) + if (cart is not null && cart.ProductOrders is not null && cart.ProductOrders.Count == 0) { return View("Index", new CartResult { Cart = cart }); } @@ -168,8 +156,8 @@ public async Task CheckoutAsync() cart.Order.OnsiteInstallation = true; // Add the call out charge and install estimate to the Cart - Product onsite = await Product.GetByIdAsync(Guid.Parse("b174c76a-e067-4a6a-abcf-53b6d3a848e4"), _postgresql); - Product estimate = await Product.GetByIdAsync(Guid.Parse("a032b3ba-da57-4ad3-90ec-c59a3505b075"), _postgresql); + Product onsite = await Product.GetByIdAsync(Guid.Parse("b174c76a-e067-4a6a-abcf-53b6d3a848e4"), _postgresql) ?? new(); + Product estimate = await Product.GetByIdAsync(Guid.Parse("a032b3ba-da57-4ad3-90ec-c59a3505b075"), _postgresql) ?? new(); // Sum all of the install time estimates. decimal totalInstallTime = 0m; @@ -243,17 +231,26 @@ public async Task ExistingOrderAsync(Guid Id, bool? AddPortingInf if (item.ProductId != Guid.Empty) { var product = await Product.GetByIdAsync(item.ProductId, _postgresql).ConfigureAwait(false); - products.Add(product); + if (product is not null) + { + products.Add(product); + } } else if (item.ServiceId != Guid.Empty) { var service = await Service.GetAsync(item.ServiceId, _postgresql).ConfigureAwait(false); - services.Add(service); + if (service is not null) + { + services.Add(service); + } } else if (item.CouponId is not null) { var coupon = await Coupon.GetByIdAsync(item.CouponId ?? Guid.NewGuid(), _postgresql).ConfigureAwait(false); - coupons.Add(coupon); + if (coupon is not null) + { + coupons.Add(coupon); + } } } @@ -262,7 +259,7 @@ public async Task ExistingOrderAsync(Guid Id, bool? AddPortingInf var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders.ToList(), Products = products, Services = services, @@ -282,8 +279,8 @@ public async Task ExistingOrderAsync(Guid Id, bool? AddPortingInf return View("Success", new OrderWithPorts { Order = order, - PortRequest = portRequest, - PhoneNumbers = cart.PortedPhoneNumbers.ToArray() + PortRequest = portRequest ?? new(), + PhoneNumbers = [.. cart.PortedPhoneNumbers] }); } else @@ -306,22 +303,22 @@ public async Task PortingInformationForOrderByIdAsync(Guid Id) if (Id != Guid.Empty) { var order = await Order.GetByIdAsync(Id, _postgresql).ConfigureAwait(false); - var portRequest = await PortRequest.GetByOrderIdAsync(order.OrderId, _postgresql).ConfigureAwait(false); - var portedPhoneNumbers = await PortedPhoneNumber.GetByOrderIdAsync(order.OrderId, _postgresql).ConfigureAwait(false); - - if (portedPhoneNumbers.Any()) + if (order is not null) { - return View("Success", new OrderWithPorts + var portRequest = await PortRequest.GetByOrderIdAsync(order.OrderId, _postgresql).ConfigureAwait(false); + var portedPhoneNumbers = await PortedPhoneNumber.GetByOrderIdAsync(order.OrderId, _postgresql).ConfigureAwait(false); + + if (portedPhoneNumbers.Any()) { - Order = order, - PortRequest = portRequest, - PhoneNumbers = portedPhoneNumbers.ToArray() - }); - } - else - { - return Redirect($"/Cart/Order/{order.OrderId}"); + return View("Success", new OrderWithPorts + { + Order = order, + PortRequest = portRequest ?? new(), + PhoneNumbers = portedPhoneNumbers.ToArray() + }); + } } + return Redirect($"/Cart/Order/{order?.OrderId}"); } else { @@ -446,7 +443,7 @@ public async Task SubmitAsync(CartResult input) } } - if (cart.ProductOrders is null || !cart.ProductOrders.Any()) + if (cart.ProductOrders is null || cart.ProductOrders.Count == 0) { // Give the user a better error message and tell them to try again // Maybe save the cart to the database when the go to the cart page or when they hit the checkout button? @@ -507,7 +504,7 @@ public async Task SubmitAsync(CartResult input) if (submittedOrder) { bool NoEmail = order.NoEmail; - order = await Order.GetByIdAsync(order.OrderId, _postgresql).ConfigureAwait(false); + order = await Order.GetByIdAsync(order.OrderId, _postgresql).ConfigureAwait(false) ?? new(); order.NoEmail = NoEmail; // Submit the number orders and track the total cost. @@ -575,8 +572,8 @@ public async Task SubmitAsync(CartResult input) if (cart.Products is not null && cart.Products.Count > 0) { // Add the call out charge and install estimate to the Cart - Product onsite = await Product.GetByIdAsync(Guid.Parse("b174c76a-e067-4a6a-abcf-53b6d3a848e4"), _postgresql); - Product estimate = await Product.GetByIdAsync(Guid.Parse("a032b3ba-da57-4ad3-90ec-c59a3505b075"), _postgresql); + Product onsite = await Product.GetByIdAsync(Guid.Parse("b174c76a-e067-4a6a-abcf-53b6d3a848e4"), _postgresql) ?? new(); + Product estimate = await Product.GetByIdAsync(Guid.Parse("a032b3ba-da57-4ad3-90ec-c59a3505b075"), _postgresql) ?? new(); // Sum all of the install time estimates. decimal totalInstallTime = 0m; @@ -767,8 +764,8 @@ public async Task SubmitAsync(CartResult input) { if (coupon.Name.Contains("20")) { - var discountTo20 = cart?.PhoneNumbers is not null && cart.PhoneNumbers.Any() ? cart.PhoneNumbers.Count * 20 : - cart?.PurchasedPhoneNumbers is not null && cart.PurchasedPhoneNumbers.Any() ? cart.PurchasedPhoneNumbers.Count * 20 : 0; + var discountTo20 = cart?.PhoneNumbers is not null && cart.PhoneNumbers.Count != 0 ? cart.PhoneNumbers.Count * 20 : + cart?.PurchasedPhoneNumbers is not null && cart.PurchasedPhoneNumbers.Count != 0 ? cart.PurchasedPhoneNumbers.Count * 20 : 0; totalCost -= totalNumberPurchasingCost - discountTo20; onetimeItems.Add(new Line_Items { @@ -792,7 +789,7 @@ public async Task SubmitAsync(CartResult input) } else if (coupon.Type == "Service") { - var servicesToDiscount = cart?.Services is not null && cart.Services.Any() ? cart?.Services?.Where(x => x.Name.Contains("5G")).ToArray() : null; + var servicesToDiscount = cart?.Services is not null && cart.Services.Count != 0 ? cart?.Services?.Where(x => x.Name.Contains("5G")).ToArray() : null; if (servicesToDiscount is not null) { var partnerDiscount = 0; @@ -832,7 +829,7 @@ public async Task SubmitAsync(CartResult input) } // Handle hardware installation scenarios, if hardware is in the order. - if (cart?.Products is not null && cart.Products.Any()) + if (cart?.Products is not null && cart.Products.Count != 0) { if (!order.OnsiteInstallation) { @@ -975,13 +972,13 @@ Accelerate Networks var newBillingClient = new ClientDatum { name = string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName, - contacts = new ClientContact[] { - new ClientContact { + contacts = [ + new() { email = order.Email, first_name = order.FirstName, last_name = order.LastName } - }, + ], address1 = order.Address, address2 = order.Address2, city = order.City, @@ -1010,7 +1007,7 @@ Accelerate Networks var upfrontInvoice = new InvoiceDatum { client_id = billingClient.id, - line_items = onetimeItems.ToArray(), + line_items = [.. onetimeItems], tax_name1 = billingTaxRate.name, tax_rate1 = billingTaxRate.rate }; @@ -1023,7 +1020,7 @@ Accelerate Networks var reoccurringInvoice = new InvoiceDatum { client_id = billingClient.id, - line_items = reoccuringItems.ToArray(), + line_items = [.. reoccuringItems], tax_name1 = billingTaxRate.name, tax_rate1 = billingTaxRate.rate, entity_type = "quote", @@ -1032,7 +1029,7 @@ Accelerate Networks var hiddenReoccurringInvoice = new ReccurringInvoiceDatum { client_id = billingClient.id, - line_items = reoccuringItems.ToArray(), + line_items = [.. reoccuringItems], tax_name1 = billingTaxRate.name, tax_rate1 = billingTaxRate.rate, entity_type = "recurringInvoice", @@ -1043,7 +1040,7 @@ Accelerate Networks }; // Submit them to the billing system if they have items. - if (upfrontInvoice.line_items.Any() && reoccurringInvoice.line_items.Any()) + if (upfrontInvoice.line_items.Length != 0 && reoccurringInvoice.line_items.Length != 0) { // Retry once on invoice creation failures. try @@ -1108,7 +1105,7 @@ Accelerate Networks Log.Fatal(JsonSerializer.Serialize(reoccurringInvoice)); } } - else if (reoccurringInvoice.line_items.Any()) + else if (reoccurringInvoice.line_items.Length != 0) { try { @@ -1163,7 +1160,7 @@ Accelerate Networks Log.Fatal(JsonSerializer.Serialize(reoccurringInvoice)); } } - else if (upfrontInvoice.line_items.Any()) + else if (upfrontInvoice.line_items.Length != 0) { try { @@ -1224,7 +1221,7 @@ Accelerate Networks var reoccurringInvoice = new ReccurringInvoiceDatum { client_id = billingClient.id, - line_items = reoccuringItems.ToArray(), + line_items = [.. reoccuringItems], tax_name1 = billingTaxRate.name, tax_rate1 = billingTaxRate.rate, entity_type = "recurringInvoice", @@ -1237,7 +1234,7 @@ Accelerate Networks // Submit them to the billing system if they have items. - if (upfrontInvoice.line_items.Any() && reoccurringInvoice.line_items.Any()) + if (upfrontInvoice.line_items.Length != 0 && reoccurringInvoice.line_items.Length != 0) { try { @@ -1302,7 +1299,7 @@ Accelerate Networks } - else if (reoccurringInvoice.line_items.Any()) + else if (reoccurringInvoice.line_items.Length != 0) { // Bill upfront for the first month of reoccurring service so that we can get their payment information on file. upfrontInvoice.line_items = reoccurringInvoice.line_items; @@ -1367,7 +1364,7 @@ Accelerate Networks Log.Fatal(JsonSerializer.Serialize(reoccurringInvoice)); } } - else if (upfrontInvoice.line_items.Any()) + else if (upfrontInvoice.line_items.Length != 0) { try { @@ -1531,7 +1528,7 @@ Accelerate Networks Start = new CalDateTime(order.InstallDate.GetValueOrDefault()), End = new CalDateTime(end), Summary = "Accelerate Networks Phone Install", - Attendees = new List { attendee, new Attendee { CommonName = "Accelerate Networks", Rsvp = true, Value = ourRep } }, + Attendees = [attendee, new() { CommonName = "Accelerate Networks", Rsvp = true, Value = ourRep }], Organizer = new Organizer { CommonName = "Accelerate Networks", Value = new Uri($"mailto:{_emailOrders}") }, }; @@ -1564,14 +1561,14 @@ Accelerate Networks order.BackgroundWorkCompleted = false; var checkOrderUpdate = order.PutAsync(_postgresql).ConfigureAwait(false); - if (cart is not null && cart.PortedPhoneNumbers is not null && cart.PortedPhoneNumbers.Any()) + if (cart is not null && cart.PortedPhoneNumbers is not null && cart.PortedPhoneNumbers.Count != 0) { HttpContext.Session.Clear(); return View("Success", new OrderWithPorts { Order = order, - PhoneNumbers = cart.PortedPhoneNumbers.ToArray() + PhoneNumbers = [.. cart.PortedPhoneNumbers] }); } else @@ -1596,12 +1593,12 @@ Accelerate Networks } } - if (cart is not null && cart.Order is not null && cart.PortedPhoneNumbers is not null && cart.PortedPhoneNumbers.Any()) + if (cart is not null && cart.Order is not null && cart.PortedPhoneNumbers is not null && cart.PortedPhoneNumbers.Count != 0) { return View("Success", new OrderWithPorts { Order = cart.Order, - PhoneNumbers = cart.PortedPhoneNumbers.ToArray() + PhoneNumbers = [.. cart.PortedPhoneNumbers] }); } else diff --git a/NumberSearch.Mvc/Controllers/LookupController.cs b/NumberSearch.Mvc/Controllers/LookupController.cs index 2d62882c..3f0181a3 100644 --- a/NumberSearch.Mvc/Controllers/LookupController.cs +++ b/NumberSearch.Mvc/Controllers/LookupController.cs @@ -20,27 +20,18 @@ namespace NumberSearch.Mvc.Controllers { [ApiExplorerSettings(IgnoreApi = true)] [EnableRateLimiting("lookup")] - public class LookupController : Controller + public class LookupController(MvcConfiguration mvcConfiguration) : Controller { - private readonly string _postgresql; - private readonly string _bulkVSKey; - private readonly string _bulkVSUsername; - private readonly string _bulkVSPassword; - private readonly string _callWithUsAPIkey; - - public LookupController(MvcConfiguration mvcConfiguration) - { - _postgresql = mvcConfiguration.PostgresqlProd; - _bulkVSKey = mvcConfiguration.BulkVSAPIKEY; - _bulkVSUsername = mvcConfiguration.BulkVSUsername; - _bulkVSPassword = mvcConfiguration.BulkVSPassword; - _callWithUsAPIkey = mvcConfiguration.CallWithUsAPIKEY; - } + private readonly string _postgresql = mvcConfiguration.PostgresqlProd; + private readonly string _bulkVSKey = mvcConfiguration.BulkVSAPIKEY; + private readonly string _bulkVSUsername = mvcConfiguration.BulkVSUsername; + private readonly string _bulkVSPassword = mvcConfiguration.BulkVSPassword; + private readonly string _callWithUsAPIkey = mvcConfiguration.CallWithUsAPIKEY; [HttpGet] [DisableRateLimiting] [ResponseCache(Duration = 30, Location = ResponseCacheLocation.Any, NoStore = false)] - public async Task IndexAsync(string dialedNumber) + public IActionResult Index(string dialedNumber) { if (string.IsNullOrWhiteSpace(dialedNumber)) { @@ -238,9 +229,10 @@ public async Task VerifyPortabilityAsync(string dialedNumber) lectype = canada?.Prefix_Type ?? string.Empty, city = canada?.Ratecenter ?? string.Empty, province = canada?.State ?? string.Empty, - }); - - checkNumber.LosingCarrier = portable?.LosingCarrier ?? string.Empty; + }) + { + LosingCarrier = portable?.LosingCarrier ?? string.Empty + }; // Warning this costs $$$$ var numberName = await CnamBulkVs.GetAsync(phoneNumber.DialedNumber ?? string.Empty, _bulkVSKey); diff --git a/NumberSearch.Mvc/Controllers/NewClientController.cs b/NumberSearch.Mvc/Controllers/NewClientController.cs index c9dc3bd2..ae819dde 100644 --- a/NumberSearch.Mvc/Controllers/NewClientController.cs +++ b/NumberSearch.Mvc/Controllers/NewClientController.cs @@ -15,16 +15,10 @@ namespace NumberSearch.Mvc.Controllers { [ApiExplorerSettings(IgnoreApi = true)] - public class NewClientController : Controller + public class NewClientController(MvcConfiguration mvcConfiguration) : Controller { - private readonly string _postgresql; - private readonly MvcConfiguration _mvcConfiguration; - - public NewClientController(MvcConfiguration mvcConfiguration) - { - _postgresql = mvcConfiguration.PostgresqlProd; - _mvcConfiguration = mvcConfiguration; - } + private readonly string _postgresql = mvcConfiguration.PostgresqlProd; + private readonly MvcConfiguration _mvcConfiguration = mvcConfiguration; [HttpGet("Cart/Order/{orderId}/NewClient")] [ResponseCache(VaryByHeader = "User-Agent", Duration = 30, Location = ResponseCacheLocation.Any)] @@ -33,69 +27,72 @@ public async Task IndexAsync(Guid orderId) var order = await Order.GetByIdAsync(orderId, _postgresql); var productOrders = await ProductOrder.GetAsync(orderId, _postgresql).ConfigureAwait(false); var products = await Product.GetAllAsync(_postgresql).ConfigureAwait(false); - var newClient = await NewClient.GetByOrderIdAsync(order.OrderId, _postgresql).ConfigureAwait(false); + NewClient newClient = await NewClient.GetByOrderIdAsync(order?.OrderId ?? new(), _postgresql).ConfigureAwait(false) ?? new(); var phoneNumbers = productOrders.Where(x => !string.IsNullOrWhiteSpace(x.DialedNumber))?.Select(x => x.DialedNumber)?.ToArray(); var portedNumbers = await PortedPhoneNumber.GetByOrderIdAsync(orderId, _postgresql).ConfigureAwait(false); var portedStrippedNumbers = portedNumbers?.Select(x => x.PortedDialedNumber).ToArray(); - var allNumbers = phoneNumbers?.Concat(portedStrippedNumbers ?? Array.Empty())?.ToArray(); + var allNumbers = phoneNumbers?.Concat(portedStrippedNumbers ?? [])?.ToArray(); - if (newClient is null) + if (newClient is null && order?.OrderId is not null) { newClient = new NewClient { NewClientId = Guid.NewGuid(), OrderId = order.OrderId }; var checkCreate = await newClient.PostAsync(_postgresql).ConfigureAwait(false); if (checkCreate) { - newClient = await NewClient.GetByOrderIdAsync(order.OrderId, _postgresql).ConfigureAwait(false); + newClient = await NewClient.GetByOrderIdAsync(order.OrderId, _postgresql).ConfigureAwait(false) ?? new(); } } - // Gather up all the childern - newClient.ExtensionRegistrations = await ExtensionRegistration.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); - newClient.NumberDescriptions = await NumberDescription.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); - newClient.IntercomRegistrations = await IntercomRegistration.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); - newClient.SpeedDialKeys = await SpeedDialKey.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); - newClient.FollowMeRegistrations = await FollowMeRegistration.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); - newClient.PhoneMenuOptions = await PhoneMenuOption.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); - - // There is info entered make sure the users sees it. - if (newClient.IntercomRegistrations.Any()) + if (newClient is not null) { - newClient.Intercom = true; - } + // Gather up all the childern + newClient.ExtensionRegistrations = await ExtensionRegistration.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); + newClient.NumberDescriptions = await NumberDescription.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); + newClient.IntercomRegistrations = await IntercomRegistration.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); + newClient.SpeedDialKeys = await SpeedDialKey.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); + newClient.FollowMeRegistrations = await FollowMeRegistration.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); + newClient.PhoneMenuOptions = await PhoneMenuOption.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); - if (!string.IsNullOrWhiteSpace(newClient.IntercomDescription)) - { - newClient.Intercom = true; - } + // There is info entered make sure the users sees it. + if (newClient.IntercomRegistrations.Length != 0) + { + newClient.Intercom = true; + } - if (newClient.SpeedDialKeys.Any()) - { - newClient.SpeedDial = true; - } + if (!string.IsNullOrWhiteSpace(newClient.IntercomDescription)) + { + newClient.Intercom = true; + } - if (newClient.PhoneMenuOptions.Any()) - { - newClient.PhoneMenu = true; - } + if (newClient.SpeedDialKeys.Length != 0) + { + newClient.SpeedDial = true; + } - if (!string.IsNullOrWhiteSpace(newClient.TextingServiceName)) - { - newClient.TextingService = true; - } + if (newClient.PhoneMenuOptions.Length != 0) + { + newClient.PhoneMenu = true; + } - if (!string.IsNullOrWhiteSpace(newClient.OverheadPagingDescription)) - { - newClient.OverheadPaging = true; + if (!string.IsNullOrWhiteSpace(newClient.TextingServiceName)) + { + newClient.TextingService = true; + } + + if (!string.IsNullOrWhiteSpace(newClient.OverheadPagingDescription)) + { + newClient.OverheadPaging = true; + } } var form = new NewClientResult { - Order = order, - NewClient = newClient, - ProductOrders = productOrders.ToArray(), - Products = products.ToArray(), - PhoneNumbers = allNumbers ?? Array.Empty(), + Order = order ?? new(), + NewClient = newClient ?? new(), + ProductOrders = [.. productOrders], + Products = [.. products], + PhoneNumbers = allNumbers ?? [], }; return View("Index", form); @@ -161,7 +158,7 @@ public async Task SubmitNewClientAsync(NewClient newClient) if (checkUpdate) { - newClient = await NewClient.GetAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); + newClient = await NewClient.GetAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false) ?? new(); } } else @@ -170,7 +167,7 @@ public async Task SubmitNewClientAsync(NewClient newClient) if (checkCreate) { - newClient = await NewClient.GetAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); + newClient = await NewClient.GetAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false) ?? new(); } } @@ -183,7 +180,7 @@ public async Task SubmitNewClientAsync(NewClient newClient) newClient.PhoneMenuOptions = await PhoneMenuOption.GetByNewClientAsync(newClient.NewClientId, _postgresql).ConfigureAwait(false); // There is info entered make sure the users sees it. - if (newClient.IntercomRegistrations.Any()) + if (newClient.IntercomRegistrations.Length != 0) { newClient.Intercom = true; } @@ -193,12 +190,12 @@ public async Task SubmitNewClientAsync(NewClient newClient) newClient.Intercom = true; } - if (newClient.SpeedDialKeys.Any()) + if (newClient.SpeedDialKeys.Length != 0) { newClient.SpeedDial = true; } - if (newClient.PhoneMenuOptions.Any()) + if (newClient.PhoneMenuOptions.Length != 0) { newClient.PhoneMenu = true; } @@ -218,9 +215,9 @@ public async Task SubmitNewClientAsync(NewClient newClient) var phoneNumbers = productOrders.Where(x => !string.IsNullOrWhiteSpace(x.DialedNumber))?.Select(x => x.DialedNumber)?.ToArray(); var portedNumbers = await PortedPhoneNumber.GetByOrderIdAsync(newClient.OrderId, _postgresql).ConfigureAwait(false); var portedStrippedNumbers = portedNumbers?.Select(x => x.PortedDialedNumber).ToArray(); - var allNumbers = phoneNumbers?.Concat(portedStrippedNumbers ?? Array.Empty())?.ToArray(); + var allNumbers = phoneNumbers?.Concat(portedStrippedNumbers ?? [])?.ToArray(); - return View("Index", new NewClientResult { NewClient = newClient, Order = order, Products = products.ToArray(), ProductOrders = productOrders.ToArray(), PhoneNumbers = allNumbers ?? Array.Empty() }); + return View("Index", new NewClientResult { NewClient = newClient, Order = order, Products = [..products], ProductOrders = [..productOrders], PhoneNumbers = allNumbers ?? [] }); } return View("Index"); diff --git a/NumberSearch.Ops/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs b/NumberSearch.Ops/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs index dcc4ee8e..120d33de 100644 --- a/NumberSearch.Ops/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs +++ b/NumberSearch.Ops/Areas/Identity/Pages/Account/Manage/DownloadPersonalData.cshtml.cs @@ -4,6 +4,8 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; + +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -49,7 +51,7 @@ public async Task OnPostAsync() personalData.Add($"{l.LoginProvider} external login provider key", l.ProviderKey); } - Response.Headers.Add("Content-Disposition", "attachment; filename=PersonalData.json"); + Response.Headers.Append("Content-Disposition", "attachment; filename=PersonalData.json"); return new FileContentResult(JsonSerializer.SerializeToUtf8Bytes(personalData), "application/json"); } } diff --git a/NumberSearch.Ops/Controllers/HomeController.cs b/NumberSearch.Ops/Controllers/HomeController.cs index f9dc9fa2..5c48ec46 100644 --- a/NumberSearch.Ops/Controllers/HomeController.cs +++ b/NumberSearch.Ops/Controllers/HomeController.cs @@ -56,7 +56,7 @@ public async Task NumbersToVerify(Guid? orderId) { var orders = await _context.VerifiedPhoneNumbers.Where(x => x.OrderId == orderId).AsNoTracking().ToListAsync(); - if (orders is not null && orders.Any()) + if (orders is not null && orders.Count != 0) { foreach (var order in orders) { @@ -112,7 +112,7 @@ public async Task ShipmentsAsync(Guid? ProductShipmentId) if (checkExists is not null) { - return View("Shipments", new InventoryResult { Products = products, ProductShipments = new ProductShipment[] { checkExists }, Shipment = checkExists }); + return View("Shipments", new InventoryResult { Products = products, ProductShipments = [checkExists], Shipment = checkExists }); } else { @@ -212,7 +212,7 @@ public async Task ProductsAsync(Guid? ProductId) { var products = await _context.Products.AsNoTracking().FirstOrDefaultAsync(x => x.ProductId == ProductId); - return View("Products", new InventoryResult { Products = new Product[] { products ?? new() }, Product = products ?? new() }); + return View("Products", new InventoryResult { Products = [products ?? new()], Product = products ?? new() }); } } @@ -280,7 +280,7 @@ public async Task Coupons(Guid? couponId) // Show all orders var result = await _context.Coupons.Where(x => x.CouponId == couponId).FirstOrDefaultAsync(); - return View("Coupons", new CouponResult { Coupon = result ?? new(), Coupons = new Coupon[] { result ?? new Coupon() } }); + return View("Coupons", new CouponResult { Coupon = result ?? new(), Coupons = [result ?? new Coupon()] }); } } @@ -414,7 +414,10 @@ public async Task ResendEmails(Guid orderId, Guid emailId) response.AlertType = "alert-danger"; } - response.Emails = await _context.SentEmails.Where(x => x.OrderId == email.OrderId).ToArrayAsync(); + if (email?.OrderId is not null) + { + response.Emails = await _context.SentEmails.Where(x => x.OrderId == email.OrderId).ToArrayAsync(); + } } catch (Exception ex) { diff --git a/NumberSearch.Ops/Controllers/OrdersController.cs b/NumberSearch.Ops/Controllers/OrdersController.cs index bbc48bc7..1d202e30 100644 --- a/NumberSearch.Ops/Controllers/OrdersController.cs +++ b/NumberSearch.Ops/Controllers/OrdersController.cs @@ -26,22 +26,14 @@ namespace NumberSearch.Ops.Controllers; [ApiExplorerSettings(IgnoreApi = true)] -public class OrdersController : Controller +public class OrdersController(OpsConfig opsConfig, + numberSearchContext context, + UserManager userManager) : Controller { - private readonly string _invoiceNinjaToken; - private readonly numberSearchContext _context; - private readonly UserManager _userManager; - private readonly OpsConfig _config; - - public OrdersController(OpsConfig opsConfig, - numberSearchContext context, - UserManager userManager) - { - _config = opsConfig; - _invoiceNinjaToken = opsConfig.InvoiceNinjaToken; - _context = context; - _userManager = userManager; - } + private readonly string _invoiceNinjaToken = opsConfig.InvoiceNinjaToken; + private readonly numberSearchContext _context = context; + private readonly UserManager _userManager = userManager; + private readonly OpsConfig _config = opsConfig; [HttpGet("/Orders/Search")] public async Task SearchOrdersAsync(string query) @@ -91,12 +83,12 @@ public async Task SearchOrdersAsync(string query) if (orders.Count > 1) { var searchResults = orders.Where(x => x.BusinessName != null - && x.BusinessName.ToLowerInvariant().Contains(query.ToLowerInvariant())).ToList(); + && x.BusinessName.Contains(query, StringComparison.InvariantCultureIgnoreCase)).ToList(); // First and Last Name searchResults.AddRange(orders.Where(x => !string.IsNullOrWhiteSpace(x.FirstName) && !string.IsNullOrWhiteSpace(x.LastName) - && $"{x.FirstName} {x.LastName}".ToLowerInvariant().Contains(query.ToLowerInvariant()))); + && $"{x.FirstName} {x.LastName}".Contains(query, StringComparison.InvariantCultureIgnoreCase))); // Phone Number searchResults.AddRange(orders.Where(x => !string.IsNullOrWhiteSpace(x?.ContactPhoneNumber) @@ -173,7 +165,7 @@ public async Task Orders(Guid? orderId) return View("Orders", new OrderResult { - Orders = pairs.ToArray(), + Orders = [.. pairs], Products = products, Services = services, PortedPhoneNumbers = portedPhoneNumbers, @@ -255,7 +247,7 @@ public async Task Orders(Guid? orderId) var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -265,7 +257,7 @@ public async Task Orders(Guid? orderId) PurchasedPhoneNumbers = purchasedPhoneNumbers }; - return View("OrderEdit", new EditOrderResult { Order = order, PortRequest = portRequest ?? new(), ProductItems = productItems, EmergencyInformation = e911Registrations.ToArray(), Cart = cart }); + return View("OrderEdit", new EditOrderResult { Order = order, PortRequest = portRequest ?? new(), ProductItems = productItems, EmergencyInformation = [.. e911Registrations], Cart = cart }); } } } @@ -329,7 +321,7 @@ public async Task Quotes() return View("Quotes", new OrderResult { - Orders = pairs.ToArray(), + Orders = [.. pairs], Products = products, Services = services, PortedPhoneNumbers = portedPhoneNumbers, @@ -355,7 +347,7 @@ public async Task OrderUpdate([Bind("OrderId,FirstName,LastName,E { // Format the address information Log.Information($"[Checkout] Parsing address data from {order.Address}"); - var addressParts = order?.UnparsedAddress?.Split(", ") ?? Array.Empty(); + var addressParts = order?.UnparsedAddress?.Split(", ") ?? []; if (order is not null && addressParts is not null && addressParts.Length > 4) { order.Address = addressParts[0] ?? string.Empty; @@ -458,7 +450,7 @@ public async Task OrderUpdate([Bind("OrderId,FirstName,LastName,E if (order.OnsiteInstallation != existingOrder.OnsiteInstallation) { - var productOrders = await _context.ProductOrders.Where(x => x.OrderId == order.OrderId).ToListAsync(); + List productOrders = await _context.ProductOrders.Where(x => x.OrderId == order.OrderId).ToListAsync(); var productsToGet = productOrders.Where(x => x.ProductId is not null && x.ProductId != Guid.Empty).Select(x => x.ProductId).ToArray(); var products = new List(); foreach (var productId in productsToGet) @@ -503,8 +495,8 @@ public async Task OrderUpdate([Bind("OrderId,FirstName,LastName,E }; // Add the install charges if they're not already in the Cart. - var checkOnsiteExists = productOrders.FirstOrDefault(x => x.ProductId == Guid.Parse("b174c76a-e067-4a6a-abcf-53b6d3a848e4")); - var checkEstimateExists = productOrders.FirstOrDefault(x => x.ProductId == Guid.Parse("a032b3ba-da57-4ad3-90ec-c59a3505b075")); + var checkOnsiteExists = productOrders?.FirstOrDefault(x => x.ProductId == Guid.Parse("b174c76a-e067-4a6a-abcf-53b6d3a848e4")); + var checkEstimateExists = productOrders?.FirstOrDefault(x => x.ProductId == Guid.Parse("a032b3ba-da57-4ad3-90ec-c59a3505b075")); if (order.OnsiteInstallation) { @@ -586,7 +578,7 @@ private async Task GetOrderEditCartAsync(Order order) return new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -644,7 +636,7 @@ public async Task RegisterE911Async(string serviceNumber, string { try { - string[] addressChunks = order.Address?.Split(" ") ?? Array.Empty(); + string[] addressChunks = order.Address?.Split(" ") ?? []; string withoutUnitNumber = string.Join(" ", addressChunks[1..]); var checkAddress = await E911Record.ValidateAddressAsync(addressChunks[0], withoutUnitNumber, order.Address2 ?? string.Empty, order.City ?? string.Empty, order.State ?? string.Empty, order.Zip ?? string.Empty, _config.BulkVSUsername, @@ -658,7 +650,7 @@ public async Task RegisterE911Async(string serviceNumber, string { var response = await E911Record.PostAsync($"1{phoneNumber.DialedNumber}", string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName, - checkAddress.AddressID, Array.Empty(), _config.BulkVSUsername, _config.BulkVSPassword); + checkAddress.AddressID, [], _config.BulkVSUsername, _config.BulkVSPassword); if (response.Status is "Success") { @@ -674,7 +666,7 @@ public async Task RegisterE911Async(string serviceNumber, string City = response.City, DateIngested = DateTime.Now, DialedNumber = phoneNumber.DialedNumber, - Sms = response.Sms.Any() ? string.Join(',', response.Sms) : string.Empty, + Sms = response.Sms.Length != 0 ? string.Join(',', response.Sms) : string.Empty, State = response.State, EmergencyInformationId = Guid.NewGuid(), IngestedFrom = "BulkVS", @@ -735,7 +727,7 @@ public async Task RegisterE911Async(string serviceNumber, string var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -790,7 +782,7 @@ public async Task RegisterE911Async(string serviceNumber, string var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -846,7 +838,7 @@ public async Task RegisterE911Async(string serviceNumber, string var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -902,7 +894,7 @@ public async Task RegisterE911Async(string serviceNumber, string var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -958,7 +950,7 @@ public async Task RegisterE911Async(string serviceNumber, string var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -1014,7 +1006,7 @@ public async Task RegisterE911Async(string serviceNumber, string var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -1062,7 +1054,7 @@ public async Task OrderMergeAsync(Guid orderId, Guid mergeId) var portedPhoneNumbers = await _context.PortedPhoneNumbers.Where(x => x.OrderId == child.OrderId).ToListAsync(); var portRequests = await _context.PortRequests.Where(x => x.OrderId == child.OrderId).ToListAsync(); - List duplicateIds = new(); + List duplicateIds = []; foreach (var item in purchasedPhoneNumbers) { @@ -1167,7 +1159,7 @@ public async Task OrderMergeAsync(Guid orderId, Guid mergeId) var cart = new Cart { Order = parent, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -1222,7 +1214,7 @@ public async Task OrderMergeAsync(Guid orderId, Guid mergeId) var cart = new Cart { Order = parent, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -1278,7 +1270,7 @@ public async Task OrderMergeAsync(Guid orderId, Guid mergeId) var cart = new Cart { Order = parent, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -1319,7 +1311,7 @@ public async Task CreateProductItemsFromOrder(Guid? orderId, stri string carrier = string.Empty; string trackingNumber = string.Empty; - HardwareOrder.Orderline[] orderLines = Array.Empty(); + HardwareOrder.Orderline[] orderLines = []; if (!string.IsNullOrWhiteSpace(teleDynamicsOrderNumber)) { @@ -1359,7 +1351,7 @@ public async Task CreateProductItemsFromOrder(Guid? orderId, stri products.Add(product); // If items already exist, do not create them twice. - if (!productItems.Any() && item?.Quantity is not null && item.Quantity > 0) + if (productItems.Length == 0 && item?.Quantity is not null && item.Quantity > 0) { var matches = orderLines.FirstOrDefault(x => x.PartNumber.Contains(product.VendorPartNumber))?.SerializationInformation; @@ -1411,10 +1403,10 @@ public async Task CreateProductItemsFromOrder(Guid? orderId, stri } } } - else if (productItems.Any() && item?.Quantity is not null && item.Quantity > 0) + else if (productItems.Length != 0 && item?.Quantity is not null && item.Quantity > 0) { // Update them with the current tracking info - List devices = new(); + List devices = []; foreach (var line in orderLines) { foreach (var device in line.SerializationInformation) @@ -1482,7 +1474,7 @@ public async Task CreateProductItemsFromOrder(Guid? orderId, stri var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -1563,7 +1555,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) var cart = new Cart { Order = order, - PhoneNumbers = new List(), + PhoneNumbers = [], ProductOrders = productOrders, Products = products, Services = services, @@ -1573,7 +1565,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) PurchasedPhoneNumbers = purchasedPhoneNumbers }; - if (cart is not null && cart.ProductOrders.Any()) + if (cart is not null && cart.ProductOrders.Count != 0) { try { @@ -1735,7 +1727,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) } // Handle hardware installation scenarios, if hardware is in the order. - if (cart.Products.Any()) + if (cart.Products.Count != 0) { if (order.OnsiteInstallation) { @@ -1795,7 +1787,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) if (specificTaxRate is not null && specificTaxRate.loccode > 0 && specificTaxRate.loccode < 15 && string.IsNullOrWhiteSpace(specificTaxRate.rate?.name) && (order.State is "WA" || order.State is "Washington")) { - var rateName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(specificTaxRate.rate.name.ToLowerInvariant()); + var rateName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(specificTaxRate.rate?.name.ToLowerInvariant() ?? string.Empty); var taxRateName = $"{rateName}, WA - {specificTaxRate.loccode}"; var taxRateValue = specificTaxRate.rate1 * 100M; @@ -1835,13 +1827,13 @@ public async Task OrderNewInvoicesAsync(Guid orderId) var newBillingClient = new ClientDatum { name = string.IsNullOrWhiteSpace(order.BusinessName) ? $"{order.FirstName} {order.LastName}" : order.BusinessName, - contacts = new ClientContact[] { + contacts = [ new ClientContact { email = order.Email ?? string.Empty, first_name = order?.FirstName ?? string.Empty, last_name = order?.LastName ?? string.Empty } - }, + ], address1 = order?.Address ?? string.Empty, address2 = order?.Address2 ?? string.Empty, city = order?.City ?? string.Empty, @@ -1869,7 +1861,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) var upfrontInvoice = new InvoiceDatum { id = billingClient.id, - line_items = onetimeItems.ToArray(), + line_items = [.. onetimeItems], tax_name1 = billingTaxRate.name, tax_rate1 = billingTaxRate.rate, client_id = billingClient.id @@ -1883,7 +1875,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) var reoccurringInvoice = new InvoiceDatum { client_id = billingClient.id, - line_items = reoccurringItems.ToArray(), + line_items = [.. reoccurringItems], tax_name1 = billingTaxRate.name, tax_rate1 = billingTaxRate.rate, entity_type = "quote", @@ -1892,7 +1884,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) var hiddenReoccurringInvoice = new ReccurringInvoiceDatum { client_id = billingClient.id, - line_items = reoccurringItems.ToArray(), + line_items = [.. reoccurringItems], tax_name1 = billingTaxRate.name, tax_rate1 = billingTaxRate.rate, entity_type = "recurringInvoice", @@ -1904,7 +1896,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) string partialMessage = string.Empty; // Submit them to the billing system if they have items. - if (upfrontInvoice.line_items.Any() && reoccurringInvoice.line_items.Any()) + if (upfrontInvoice.line_items.Length != 0 && reoccurringInvoice.line_items.Length != 0) { var BillingClientId = string.Empty; var BillingInvoiceId = string.Empty; @@ -2064,7 +2056,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) } } - else if (reoccurringInvoice.line_items.Any()) + else if (reoccurringInvoice.line_items.Length != 0) { var createNewReoccurringInvoice = new InvoiceDatum(); try @@ -2141,7 +2133,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) return View("OrderEdit", new EditOrderResult { Order = order, Cart = cart, Message = $"Failed to update order with the new invoices. 😡 {ex.Message}", AlertType = "alert-danger" }); } } - else if (upfrontInvoice.line_items.Any()) + else if (upfrontInvoice.line_items.Length != 0) { var createNewOneTimeInvoice = new InvoiceDatum(); @@ -2234,7 +2226,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) var reoccurringInvoice = new ReccurringInvoiceDatum { client_id = billingClient.id, - line_items = reoccurringItems.ToArray(), + line_items = [.. reoccurringItems], tax_name1 = billingTaxRate.name, tax_rate1 = billingTaxRate.rate, entity_type = "recurringInvoice", @@ -2246,7 +2238,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) string partialMessage = string.Empty; // Submit them to the billing system if they have items. - if (upfrontInvoice.line_items.Any() && reoccurringInvoice.line_items.Any() && order is not null) + if (upfrontInvoice.line_items.Length != 0 && reoccurringInvoice.line_items.Length != 0 && order is not null) { var createNewOneTimeInvoice = new InvoiceDatum(); @@ -2377,7 +2369,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) return View("OrderEdit", new EditOrderResult { Order = order, Cart = cart, Message = $"Failed to update the order with the new invoices. 😡 {ex.Message}", AlertType = "alert-danger" }); } } - else if (reoccurringInvoice.line_items.Any() && order is not null) + else if (reoccurringInvoice.line_items.Length != 0 && order is not null) { var createNewReoccurringInvoice = new ReccurringInvoiceDatum(); @@ -2454,7 +2446,7 @@ public async Task OrderNewInvoicesAsync(Guid orderId) } } - else if (upfrontInvoice.line_items.Any() && order is not null) + else if (upfrontInvoice.line_items.Length != 0 && order is not null) { var createNewOneTimeInvoice = new InvoiceDatum(); @@ -2651,7 +2643,7 @@ public async Task ExportToCSV() var result = new OrderResult { - Orders = pairs.ToArray(), + Orders = [.. pairs], Products = products, Services = services, PortedPhoneNumbers = portedPhoneNumbers, @@ -2689,7 +2681,7 @@ public async Task ExportToCSV() return View("Quotes", new OrderResult { - Orders = pairs.ToArray(), + Orders = [.. pairs], Products = products, Services = services, PortedPhoneNumbers = portedPhoneNumbers, diff --git a/NumberSearch.Ops/Controllers/PortRequestsController.cs b/NumberSearch.Ops/Controllers/PortRequestsController.cs index fc470e66..4aaaaea2 100644 --- a/NumberSearch.Ops/Controllers/PortRequestsController.cs +++ b/NumberSearch.Ops/Controllers/PortRequestsController.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using NumberSearch.DataAccess; using NumberSearch.DataAccess.BulkVS; using Serilog; @@ -178,6 +177,8 @@ public async Task PortRequests(Guid? orderId) [Route("/Home/BillImage/{orderId}/")] public async Task DownloadAsync(string orderId, string fileName) { + var OrderId = new Guid(orderId); + // Create a BlobServiceClient object which will be used to create a container client BlobServiceClient blobServiceClient = new(_azureStorage); @@ -200,9 +201,9 @@ public async Task DownloadAsync(string orderId, string fileName) { return View("PortRequestEdit", new PortRequestResult { - Order = await _context.Orders.FirstOrDefaultAsync(x => x.OrderId == new Guid(orderId)), - PortRequest = await _context.PortRequests.FirstOrDefaultAsync(x => x.OrderId == new Guid(orderId)), - PhoneNumbers = await _context.PortedPhoneNumbers.Where(x => x.OrderId == new Guid(orderId)).ToArrayAsync(), + Order = await _context.Orders.FirstOrDefaultAsync(x => x.OrderId == OrderId) ?? new(), + PortRequest = await _context.PortRequests.FirstOrDefaultAsync(x => x.OrderId == OrderId) ?? new(), + PhoneNumbers = await _context.PortedPhoneNumbers.Where(x => x.OrderId == OrderId).ToArrayAsync(), Message = $"❌ Couldn't find the bill image {fileName} for Order {orderId}." }); } @@ -458,7 +459,7 @@ public async Task PortRequestUpdate(PortRequestResult result, Gui public async Task UnifiedPortRequestAsync(Guid? OrderId, bool ForceManual) { // ForceManual will overwrite the Zip to a value of "1". BulkVS claims this will break their automated processes and force them to review the request manually. - var responseMessages = new List(); + List responseMessages = []; if (OrderId is null || OrderId == Guid.Empty) { @@ -477,7 +478,7 @@ public async Task UnifiedPortRequestAsync(Guid? OrderId, bool For var numbers = await _context.PortedPhoneNumbers .Where(x => x.OrderId == order.OrderId && string.IsNullOrWhiteSpace(x.ExternalPortRequestId)).ToArrayAsync(); - if (numbers is null || !numbers.Any()) + if (numbers is null || numbers.Length == 0) { numbers = await _context.PortedPhoneNumbers.Where(x => x.OrderId == order.OrderId).ToArrayAsync(); @@ -491,7 +492,7 @@ public async Task UnifiedPortRequestAsync(Guid? OrderId, bool For } // Submit the local numbers to BulkVS in a port request. - if (numbers.Any()) + if (numbers.Length != 0) { try { @@ -577,7 +578,7 @@ public async Task UnifiedPortRequestAsync(Guid? OrderId, bool For Note = "If the port completion date requested is unavailable please pick the next available date and set the port to complete at 8pm that day." }; - await note.PostAsync(bulkResponse.OrderId, _bulkVSusername, _bulkVSpassword); + await note.PostAsync(bulkResponse?.OrderId ?? string.Empty, _bulkVSusername, _bulkVSpassword); if (bulkResponse is not null && !string.IsNullOrWhiteSpace(bulkResponse.Description)) { @@ -680,7 +681,7 @@ public async Task UnifiedPortRequestAsync(Guid? OrderId, bool For Note = "If the port completion date requested is unavailable please pick the next available date and set the port to complete at 8pm that day." }; - await note.PostAsync(bulkResponse.OrderId, _bulkVSusername, _bulkVSpassword); + await note.PostAsync(bulkResponse?.OrderId ?? string.Empty, _bulkVSusername, _bulkVSpassword); if (bulkResponse is not null && !string.IsNullOrWhiteSpace(bulkResponse.Description)) { @@ -750,7 +751,7 @@ public async Task UnifiedPortRequestAsync(Guid? OrderId, bool For PortRequest = portRequest ?? new(), PhoneNumbers = numbers, AlertType = "alert-success", - Message = responseMessages.Any() ? string.Join(", ", responseMessages.ToArray()) : "🥰 Port Request was submitted to our vendors!" + Message = responseMessages.Count != 0 ? string.Join(", ", [.. responseMessages]) : "🥰 Port Request was submitted to our vendors!" }); } } diff --git a/NumberSearch.Ops/Views/Carriers/Index.cshtml b/NumberSearch.Ops/Views/Carriers/Index.cshtml index 3a098572..452aa97c 100644 --- a/NumberSearch.Ops/Views/Carriers/Index.cshtml +++ b/NumberSearch.Ops/Views/Carriers/Index.cshtml @@ -43,9 +43,12 @@ - @foreach (var lectype in Model?.Select(x => x.Lectype).Distinct()) + @if (Model is not null && Model.Count() != 0) { - @Model?.Where(x => x.Lectype == lectype).Count() - @lectype + foreach (var lectype in Model.Select(x => x.Lectype).Distinct()) + { + @Model?.Where(x => x.Lectype == lectype).Count() - @lectype + } } @@ -83,7 +86,8 @@ - @{ + @if (Model is not null && Model.Count() != 0) + { var topLevelCarriers = Model.DistinctBy(y => y.Name).OrderByDescending(x => x?.Name); foreach (var product in topLevelCarriers) { @@ -176,38 +180,41 @@ - @foreach (var product in Model.OrderByDescending(x => x?.Name)) + @if (Model is not null && Model.Count() != 0) { - - - @product?.Name - - - @product?.Type - - - @product?.Lec - - - @product?.Lectype - - - @product?.Name - - - @product?.Ocn - - - @product?.Spid - - -
- Edit - Details - Delete -
- - + foreach (var product in Model.OrderByDescending(x => x?.Name)) + { + + + @product?.Name + + + @product?.Type + + + @product?.Lec + + + @product?.Lectype + + + @product?.Name + + + @product?.Ocn + + + @product?.Spid + + +
+ Edit + Details + Delete +
+ + + } } diff --git a/NumberSearch.Ops/Views/Lookups/Index.cshtml b/NumberSearch.Ops/Views/Lookups/Index.cshtml index 2290c102..cb88992f 100644 --- a/NumberSearch.Ops/Views/Lookups/Index.cshtml +++ b/NumberSearch.Ops/Views/Lookups/Index.cshtml @@ -75,7 +75,7 @@
- New Carrier + New Carrier Edit Details Delete diff --git a/NumberSearch.Ops/Views/Messaging/Failed.cshtml b/NumberSearch.Ops/Views/Messaging/Failed.cshtml index 90aca58f..0ba2ce8e 100644 --- a/NumberSearch.Ops/Views/Messaging/Failed.cshtml +++ b/NumberSearch.Ops/Views/Messaging/Failed.cshtml @@ -36,7 +36,7 @@ { var number = failed.FirstOrDefault()?.To; var checkParse = PhoneNumbersNA.PhoneNumber.TryParse(number ?? string.Empty, out var phoneNumber); - if (checkParse && phoneNumber is not null && !string.IsNullOrWhiteSpace(number)) + if (checkParse && phoneNumber is not null && !string.IsNullOrWhiteSpace(number) && Model is not null) { var ownedPhoneNumber = Model.Owned.FirstOrDefault(x => x.DialedNumber == phoneNumber.DialedNumber); string AsDialedLink = checkParse && ownedPhoneNumber is not null ? $"{number}" : number; @@ -96,7 +96,7 @@ { var number = failed.FirstOrDefault()?.To; var checkParse = PhoneNumbersNA.PhoneNumber.TryParse(number ?? string.Empty, out var phoneNumber); - if (checkParse && phoneNumber is not null && !string.IsNullOrWhiteSpace(number)) + if (checkParse && phoneNumber is not null && !string.IsNullOrWhiteSpace(number) && Model is not null) { var ownedPhoneNumber = Model.Owned.FirstOrDefault(x => x.DialedNumber == phoneNumber.DialedNumber); string AsDialedLink = checkParse && ownedPhoneNumber is not null ? $"{number}" : number; @@ -152,28 +152,31 @@ - @foreach (var result in Model.FailedMessages) + @if (Model?.FailedMessages is not null && Model.FailedMessages.Length > 0) { - var checkParse = PhoneNumbersNA.PhoneNumber.TryParse(result.From, out var fromPhoneNumber); - var ownedPhoneNumber = Model.Owned.FirstOrDefault(x => x.DialedNumber == fromPhoneNumber.DialedNumber); - string FromLink = checkParse && ownedPhoneNumber is not null ? $"{result.From}" : result.From; - checkParse = PhoneNumbersNA.PhoneNumber.TryParse(result.To, out var toPhoneNumber); - ownedPhoneNumber = Model.Owned.FirstOrDefault(x => x.DialedNumber == toPhoneNumber.DialedNumber); - string ToLink = checkParse && ownedPhoneNumber is not null ? $"{result.To}" : result.To; + foreach (var result in Model.FailedMessages) + { + var checkParse = PhoneNumbersNA.PhoneNumber.TryParse(result.From, out var fromPhoneNumber); + var ownedPhoneNumber = Model.Owned.FirstOrDefault(x => x.DialedNumber == fromPhoneNumber.DialedNumber); + string FromLink = checkParse && ownedPhoneNumber is not null ? $"{result.From}" : result.From; + checkParse = PhoneNumbersNA.PhoneNumber.TryParse(result.To, out var toPhoneNumber); + ownedPhoneNumber = Model.Owned.FirstOrDefault(x => x.DialedNumber == toPhoneNumber.DialedNumber); + string ToLink = checkParse && ownedPhoneNumber is not null ? $"{result.To}" : result.To; - - @*@result.Succeeded*@ - @result.DateReceivedUTC.ToLocalTime().ToShortDateString() @result.DateReceivedUTC.ToLocalTime().ToShortTimeString() - @result.MessageSource - @result.MessageType - @Html.Raw(FromLink) - @Html.Raw(ToLink) - @result.RawResponse - @result.Content - @* @result.MediaURLs *@ - @*@result.RawRequest + + @*@result.Succeeded*@ + @result.DateReceivedUTC.ToLocalTime().ToShortDateString() @result.DateReceivedUTC.ToLocalTime().ToShortTimeString() + @result.MessageSource + @result.MessageType + @Html.Raw(FromLink) + @Html.Raw(ToLink) + @result.RawResponse + @result.Content + @* @result.MediaURLs *@ + @*@result.RawRequest @result.ToForward *@ - + + } } diff --git a/NumberSearch.Ops/Views/Messaging/Index.cshtml b/NumberSearch.Ops/Views/Messaging/Index.cshtml index 7da27a09..d6baa2eb 100644 --- a/NumberSearch.Ops/Views/Messaging/Index.cshtml +++ b/NumberSearch.Ops/Views/Messaging/Index.cshtml @@ -97,28 +97,31 @@ - @foreach (var result in Model.ClientRegistrations) + @if (Model?.ClientRegistrations is not null && Model.ClientRegistrations.Length != 0) { - var checkParse = PhoneNumbersNA.PhoneNumber.TryParse(result.AsDialed, out var phoneNumber); - var ownedPhoneNumber = Model.Owned.FirstOrDefault(x => x.DialedNumber == phoneNumber.DialedNumber); - string AsDialedLink = checkParse && ownedPhoneNumber is not null && ownedPhoneNumber.Active ? $"{result.AsDialed}" : $" Remove {result.AsDialed}"; - string Carrier = checkParse && ownedPhoneNumber is not null ? ownedPhoneNumber?.TwilioCarrierName ?? "No Data" : "No Data"; - string TrunkGroup = checkParse && ownedPhoneNumber is not null ? ownedPhoneNumber?.TrunkGroup ?? "No Data" : "No Data"; - - @Html.Raw(AsDialedLink) - @result.RegisteredUpstream - @result.UpstreamStatusDescription - @Carrier - @TrunkGroup - - + foreach (var result in Model.ClientRegistrations) + { + var checkParse = PhoneNumbersNA.PhoneNumber.TryParse(result.AsDialed, out var phoneNumber); + var ownedPhoneNumber = Model.Owned.FirstOrDefault(x => x.DialedNumber == phoneNumber.DialedNumber); + string AsDialedLink = checkParse && ownedPhoneNumber is not null && ownedPhoneNumber.Active ? $"{result.AsDialed}" : $" Remove {result.AsDialed}"; + string Carrier = checkParse && ownedPhoneNumber is not null ? ownedPhoneNumber?.TwilioCarrierName ?? "No Data" : "No Data"; + string TrunkGroup = checkParse && ownedPhoneNumber is not null ? ownedPhoneNumber?.TrunkGroup ?? "No Data" : "No Data"; + + @Html.Raw(AsDialedLink) + @result.RegisteredUpstream + @result.UpstreamStatusDescription + @Carrier + @TrunkGroup + + - - + + + } } @@ -132,9 +135,12 @@ - @foreach (var carrier in Model.Owned.Where(x => x.IngestedFrom != "Test" && x.Active).Select(x => x.TwilioCarrierName).Distinct()) + @if (Model?.Owned is not null && Model.Owned.Length != 0) { - + foreach (var carrier in Model.Owned.Where(x => x.IngestedFrom != "Test" && x.Active).Select(x => x.TwilioCarrierName).Distinct()) + { + + } } diff --git a/NumberSearch.Ops/Views/OwnedNumbers/OwnedNumberEdit.cshtml b/NumberSearch.Ops/Views/OwnedNumbers/OwnedNumberEdit.cshtml index a16ede2d..0228939e 100644 --- a/NumberSearch.Ops/Views/OwnedNumbers/OwnedNumberEdit.cshtml +++ b/NumberSearch.Ops/Views/OwnedNumbers/OwnedNumberEdit.cshtml @@ -369,7 +369,7 @@ else - @foreach (var product in Model?.PortedPhoneNumbers.OrderByDescending(x => x?.DateIngested)) + @foreach (var product in Model.PortedPhoneNumbers.OrderByDescending(x => x?.DateIngested)) { @@ -441,7 +441,7 @@ else - @foreach (var product in Model?.PurchasedPhoneNumbers.OrderByDescending(x => x?.DateIngested)) + @foreach (var product in Model.PurchasedPhoneNumbers.OrderByDescending(x => x?.DateIngested)) { diff --git a/NumberSearch.Ops/Views/OwnedNumbers/OwnedNumbers.cshtml b/NumberSearch.Ops/Views/OwnedNumbers/OwnedNumbers.cshtml index a2d15c6e..373ed4e8 100644 --- a/NumberSearch.Ops/Views/OwnedNumbers/OwnedNumbers.cshtml +++ b/NumberSearch.Ops/Views/OwnedNumbers/OwnedNumbers.cshtml @@ -36,11 +36,11 @@ - @Model.Results.Count() - @Model.Results.Where(x => x.Owned.Status is "Active").Count() - @Model.Results.Where(x => x.Owned.Status is "Cancelled").Count() - @Model.Results.Where(x => x.Owned.Status is "Porting In").Count() - @Model.Results.Where(x => x.Owned.Status is "Porting Out").Count() + @Model?.Results.Length + @Model?.Results.Where(x => x.Owned.Status is "Active").Count() + @Model?.Results.Where(x => x.Owned.Status is "Cancelled").Count() + @Model?.Results.Where(x => x.Owned.Status is "Porting In").Count() + @Model?.Results.Where(x => x.Owned.Status is "Porting Out").Count() @@ -59,12 +59,15 @@ - @foreach (string provider in Model.Results.Select(x => x.Owned.IngestedFrom).Distinct()) + @if (Model?.Results is not null && Model.Results.Length != 0) { - - @provider - @Model.Results.Where(x => x.Owned.IngestedFrom == provider).Count() - + foreach (string provider in Model.Results.Select(x => x.Owned.IngestedFrom).Distinct()) + { + + @provider + @Model.Results.Where(x => x.Owned.IngestedFrom == provider).Count() + + } } @@ -86,7 +89,8 @@ - @{ + @if (Model?.Results is not null && Model.Results.Length != 0) + { foreach (var number in Model.Results.Where(x => x.Owned.IngestedFrom != "Test")) { var ingestedBadge = number.Owned.IngestedFrom; @@ -171,7 +175,8 @@ @if (!string.IsNullOrWhiteSpace(number?.Owned.TrunkGroup)) {

@number?.Owned.TrunkGroup

- } else + } + else {

No trunk group data.

} @@ -191,7 +196,7 @@ @if ((string.IsNullOrWhiteSpace(number?.Owned?.SMSRoute) || number?.Owned?.SMSRoute is "Longcode not assigned to that account") - && string.IsNullOrWhiteSpace(@number?.ClientRegistration?.CallbackUrl)) + && string.IsNullOrWhiteSpace(@number?.ClientRegistration?.CallbackUrl)) {

No upstream routing found.

No message forwarding URL registered.

diff --git a/NumberSearch.Tests/Integration.cs b/NumberSearch.Tests/Integration.cs index 4c4551d4..6a7779d6 100644 --- a/NumberSearch.Tests/Integration.cs +++ b/NumberSearch.Tests/Integration.cs @@ -129,7 +129,7 @@ public async Task GetBillingInvoiceByClientIdAsync() public async Task GetBillingTaxRatesAsync() { // Act - var result = await TaxRate.GetAllAsync(invoiceNinjaToken).ConfigureAwait(false); + var result = await TaxRate.GetAllAsync(invoiceNinjaToken); // Assert Assert.NotNull(result); @@ -149,7 +149,7 @@ public async Task GetBillingTaxRatesAsync() // }; // // Act - // var result = await taxRate.PostAsync(invoiceNinjaToken).ConfigureAwait(false); + // var result = await taxRate.PostAsync(invoiceNinjaToken); // // Assert // Assert.NotNull(result); @@ -210,14 +210,14 @@ public async Task GetAllBillingClientsByEmailAsync() // }; // // Act - // var result = await testCreate.PostAsync(invoiceNinjaToken).ConfigureAwait(false); + // var result = await testCreate.PostAsync(invoiceNinjaToken); // // Assert // Assert.NotNull(result); // Assert.Equal(result.invoice_items.FirstOrDefault().notes, testCreate.invoice_items.FirstOrDefault().notes); // output.WriteLine(JsonSerializer.Serialize(result)); - // var checkSend = await result.SendInvoiceAsync(invoiceNinjaToken).ConfigureAwait(false); + // var checkSend = await result.SendInvoiceAsync(invoiceNinjaToken); // Assert.True(checkSend); //} @@ -258,7 +258,7 @@ public async Task GetBillingClientByIdAsync() // Assert.Equal(testCreate.contacts.FirstOrDefault().email, result.contacts.FirstOrDefault().email); // output.WriteLine(JsonSerializer.Serialize(result)); - // var checkDelete = await result.DeleteAsync(invoiceNinjaToken).ConfigureAwait(false); + // var checkDelete = await result.DeleteAsync(invoiceNinjaToken); // Assert.NotNull(checkDelete); // Assert.True(checkDelete.is_deleted); @@ -307,7 +307,7 @@ public async Task GetBillingClientByIdAsync() // }; // // Act - // var result = await testCreate.PostAsync(invoiceNinjaToken).ConfigureAwait(false); + // var result = await testCreate.PostAsync(invoiceNinjaToken); // // Assert // Assert.NotNull(result); @@ -316,19 +316,19 @@ public async Task GetBillingClientByIdAsync() // result.invoice_items.FirstOrDefault().notes = "Updated"; - // var updateTest = await result.PutAsync(invoiceNinjaToken).ConfigureAwait(false); + // var updateTest = await result.PutAsync(invoiceNinjaToken); // // Assert // Assert.NotNull(updateTest); // Assert.Equal(result.invoice_items.FirstOrDefault().notes, updateTest.invoice_items.FirstOrDefault().notes); // output.WriteLine(JsonSerializer.Serialize(updateTest)); - // var deleteTest = await updateTest.DeleteAsync(invoiceNinjaToken).ConfigureAwait(false); + // var deleteTest = await updateTest.DeleteAsync(invoiceNinjaToken); // Assert.NotNull(deleteTest); // Assert.True(deleteTest.is_deleted); - // var checkDelete = await testClient.DeleteAsync(invoiceNinjaToken).ConfigureAwait(false); + // var checkDelete = await testClient.DeleteAsync(invoiceNinjaToken); // Assert.NotNull(checkDelete); // Assert.True(checkDelete.is_deleted); @@ -349,7 +349,7 @@ public async Task GetBillingClientByIdAsync() // }; // // Act - // var result = await testCreate.PostAsync(invoiceNinjaToken).ConfigureAwait(false); + // var result = await testCreate.PostAsync(invoiceNinjaToken); // // Assert // Assert.NotNull(result); @@ -359,7 +359,7 @@ public async Task GetBillingClientByIdAsync() // result.contacts.FirstOrDefault().first_name = "IntegrationTest"; - // var updateResult = await result.PutAsync(invoiceNinjaToken).ConfigureAwait(false); + // var updateResult = await result.PutAsync(invoiceNinjaToken); // Assert.NotNull(result); // Assert.Equal(updateResult.name, result.name); @@ -367,7 +367,7 @@ public async Task GetBillingClientByIdAsync() // Assert.Equal(updateResult.contacts.FirstOrDefault().email, result.contacts.FirstOrDefault().email); // output.WriteLine(JsonSerializer.Serialize(result)); - // var checkDelete = await updateResult.DeleteAsync(invoiceNinjaToken).ConfigureAwait(false); + // var checkDelete = await updateResult.DeleteAsync(invoiceNinjaToken); // Assert.NotNull(checkDelete); // Assert.True(checkDelete.is_deleted); @@ -447,7 +447,7 @@ public async Task GetBillingClientByIdAsync() // string phoneNumber = "14257808879"; // // Act - // var result = await LIDBLookup.GetAsync(phoneNumber, _data247username, _data247password).ConfigureAwait(false); + // var result = await LIDBLookup.GetAsync(phoneNumber, _data247username, _data247password); // // Assert // Assert.NotNull(result); @@ -462,7 +462,7 @@ public async Task RateCenterLookupAsync() string nxx = "780"; // Act - var result = await RateCenterLookup.GetAsync(npa, nxx).ConfigureAwait(false); + var result = await RateCenterLookup.GetAsync(npa, nxx); // Assert Assert.NotNull(result); @@ -477,7 +477,7 @@ public async Task BadRateCenterLookupAsync() string nxx = "646"; // Act - var result = await RateCenterLookup.GetAsync(npa, nxx).ConfigureAwait(false); + var result = await RateCenterLookup.GetAsync(npa, nxx); // Assert Assert.True(string.IsNullOrWhiteSpace(result.RateCenter)); @@ -489,7 +489,7 @@ public async Task GetDestinationDetailsAsync() // Arrange // Act - var result = await DestinationDetails.GetByDialedNumberAsync("4254541206", _configuration.FusionPBXUsername, _configuration.FusionPBXPassword).ConfigureAwait(false); + var result = await DestinationDetails.GetByDialedNumberAsync("4254541206", _configuration.FusionPBXUsername, _configuration.FusionPBXPassword); // Assert Assert.True(result.destination_enabled); @@ -503,10 +503,10 @@ public async Task GetDomainDetailsAsync() // Arrange // Act - var result = await DomainDetails.GetByDomainIdAsync("f86cace8-9d5c-47df-b084-48e6cb58a95d", _configuration.FusionPBXUsername, _configuration.FusionPBXPassword).ConfigureAwait(false); + var result = await DomainDetails.GetByDomainIdAsync("f86cace8-9d5c-47df-b084-48e6cb58a95d", _configuration.FusionPBXUsername, _configuration.FusionPBXPassword); // Assert - Assert.True(!string.IsNullOrWhiteSpace(result.domain_name)); + Assert.False(string.IsNullOrWhiteSpace(result.domain_name)); output.WriteLine(JsonSerializer.Serialize(result)); } @@ -518,7 +518,7 @@ public async Task GetDomainDetailsAsync() // string canadaNumber = "6042400507"; // // Act - // var result = await DataAccess.CallWithUs.LRNLookup.GetAsync(canadaNumber, _callWithUsAPIkey).ConfigureAwait(false); + // var result = await DataAccess.CallWithUs.LRNLookup.GetAsync(canadaNumber, _callWithUsAPIkey); // // Assert // Assert.NotNull(result); @@ -639,7 +639,7 @@ public async Task BulkVSRESTNpaNxxGetAsyncTestAsync() // }; // // Act - // var results = await order.PostAsync(bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + // var results = await order.PostAsync(bulkVSUsername, bulkVSPassword); // // Assert // Assert.NotNull(results); @@ -654,11 +654,11 @@ public async Task BulkVSCnameLookupAsync() var number = "2064083008"; // Act - var result = await CnamBulkVs.GetAsync(number, bulkVSKey).ConfigureAwait(false); + var result = await CnamBulkVs.GetAsync(number, bulkVSKey); // Assert Assert.NotNull(result); - Assert.True(!string.IsNullOrWhiteSpace(result.name)); + Assert.False(string.IsNullOrWhiteSpace(result.name)); output.WriteLine(JsonSerializer.Serialize(result)); } @@ -669,11 +669,11 @@ public async Task BulkVSLrnLookupAsync() var number = "4252008183"; // Act - var result = await LrnBulkCnam.GetAsync(number, bulkVSKey).ConfigureAwait(false); + var result = await LrnBulkCnam.GetAsync(number, bulkVSKey); // Assert Assert.NotNull(result); - Assert.True(!string.IsNullOrWhiteSpace(result.spid)); + Assert.False(string.IsNullOrWhiteSpace(result.spid)); output.WriteLine(JsonSerializer.Serialize(result)); } @@ -688,7 +688,7 @@ public async Task BulkVSLrnLookupTollfreeAsync() // Assert Assert.NotNull(result); - Assert.True(!string.IsNullOrWhiteSpace(result.jurisdiction)); + Assert.False(string.IsNullOrWhiteSpace(result.jurisdiction)); output.WriteLine(JsonSerializer.Serialize(result)); } @@ -699,11 +699,11 @@ public async Task NumberLookupPostAsync() var number = "2064083008"; // Act - var result = await LrnBulkCnam.GetAsync(number, bulkVSKey).ConfigureAwait(false); + var result = await LrnBulkCnam.GetAsync(number, bulkVSKey); // Assert Assert.NotNull(result); - Assert.True(!string.IsNullOrWhiteSpace(result.spid)); + Assert.False(string.IsNullOrWhiteSpace(result.spid)); output.WriteLine(JsonSerializer.Serialize(result)); result.LIDBName = "IntegrationTest"; @@ -725,7 +725,7 @@ public async Task GetNumberLookupAsync() // Assert Assert.NotNull(result); - Assert.True(!string.IsNullOrWhiteSpace(result.SPID)); + Assert.False(string.IsNullOrWhiteSpace(result.SPID)); output.WriteLine(JsonSerializer.Serialize(result)); } @@ -735,7 +735,7 @@ public async Task BulkVSRESTGetAllOwnedNumbersAsync() // Arrange // Act - var results = await TnRecord.GetAsync(bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + var results = await TnRecord.GetAsync(bulkVSUsername, bulkVSPassword); // Assert Assert.NotNull(results); @@ -748,7 +748,7 @@ public async Task BulkVSRESTValidatePortabilityAsync() // Arrange var portedNumber = "8605530426"; // Act - var results = await ValidatePortability.GetAsync(portedNumber, bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + var results = await ValidatePortability.GetAsync(portedNumber, bulkVSUsername, bulkVSPassword); // Assert Assert.NotNull(results); @@ -761,7 +761,7 @@ public async Task TeleDynamicsProductCheckQuantityAsync() // Arrange var partNumber = "yea-sip-t54w"; // Act - var results = await VendorProduct.GetAsync(partNumber, _teleDynamicsUsername, _teleDynamicsPassword).ConfigureAwait(false); + var results = await VendorProduct.GetAsync(partNumber, _teleDynamicsUsername, _teleDynamicsPassword); // Assert Assert.NotNull(results); @@ -774,13 +774,13 @@ public async Task BulkVSRESTGetAllOwnedNumbersAsOwnedAsync() // Arrange // Act - var results = await TnRecord.GetOwnedAsync(bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + var results = await TnRecord.GetOwnedAsync(bulkVSUsername, bulkVSPassword); // Assert Assert.NotNull(results); Assert.NotEmpty(results); output.WriteLine(JsonSerializer.Serialize(results.FirstOrDefault())); - output.WriteLine($"{results.Count()} Owned Numbers from BulkVS"); + output.WriteLine($"{results.Length} Owned Numbers from BulkVS"); } [Fact] @@ -789,7 +789,7 @@ public async Task BulkVSRESTGetAllPortRequestsAsync() // Arrange // Act - var results = await PortTn.GetAllAsync(bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + var results = await PortTn.GetAllAsync(bulkVSUsername, bulkVSPassword); // Assert Assert.NotNull(results); @@ -801,7 +801,7 @@ public async Task BulkVSRESTValidateAddressAsync() { // Arrange // Act - var results = await E911Record.ValidateAddressAsync("", "", "", "", "", "", bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + var results = await E911Record.ValidateAddressAsync("", "", "", "", "", "", bulkVSUsername, bulkVSPassword); // Assert Assert.NotNull(results); @@ -813,7 +813,7 @@ public async Task BulkVSRESTGetExistingRecordAsync() { // Arrange // Act - var results = await E911Record.GetAsync("12062574158", bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + var results = await E911Record.GetAsync("12062574158", bulkVSUsername, bulkVSPassword); // Assert Assert.NotNull(results); @@ -825,7 +825,7 @@ public async Task BulkVSRESTProvisionAsync() { // Arrange // Act - var results = await E911Record.PostAsync("", "", "", Array.Empty(), bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + var results = await E911Record.PostAsync("", "", "", [], bulkVSUsername, bulkVSPassword); // Assert Assert.NotNull(results); @@ -852,13 +852,13 @@ public async Task BulkVSRESTGetPortRequestsAsync() // Arrange // Act - var results = await PortTn.GetAllAsync(bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + var results = await PortTn.GetAllAsync(bulkVSUsername, bulkVSPassword); // Assert Assert.NotNull(results); Assert.NotEmpty(results); - var result = await PortTn.GetAsync("1642300", bulkVSUsername, bulkVSPassword).ConfigureAwait(false); + var result = await PortTn.GetAsync("1642300", bulkVSUsername, bulkVSPassword); Assert.NotNull(result); output.WriteLine(JsonSerializer.Serialize(result)); @@ -880,13 +880,13 @@ public async Task BulkVSRESTGetPortRequestsAsync() //public async Task Call48LocalNumberLookupTestAsync() //{ // // Act - // var result = await Login.LoginAsync(_call48Username, _call48Password).ConfigureAwait(false); + // var result = await Login.LoginAsync(_call48Username, _call48Password); - // var results = await Search.GetLocalNumbersAsync("WA", string.Empty, "206", string.Empty, result.data.token).ConfigureAwait(false); + // var results = await Search.GetLocalNumbersAsync("WA", string.Empty, "206", string.Empty, result.data.token); // if (results is null || !results.data.result.Any()) // { - // results = await Search.GetLocalNumbersAsync("WA", string.Empty, "425", string.Empty, result.data.token).ConfigureAwait(false); + // results = await Search.GetLocalNumbersAsync("WA", string.Empty, "425", string.Empty, result.data.token); // } // Assert.NotEmpty(results.data.result); @@ -905,13 +905,13 @@ public async Task BulkVSRESTGetPortRequestsAsync() //public async Task Call48GetNumbersTestAsync() //{ // // Act - // var cred = await Login.LoginAsync(_call48Username, _call48Password).ConfigureAwait(false); + // var cred = await Login.LoginAsync(_call48Username, _call48Password); - // var results = await Search.GetAsync("OR", 541, cred.data.token).ConfigureAwait(false); + // var results = await Search.GetAsync("OR", 541, cred.data.token); // if (results is null || !results.Any()) // { - // results = await Search.GetAsync("WA", 425, cred.data.token).ConfigureAwait(false); + // results = await Search.GetAsync("WA", 425, cred.data.token); // } // Assert.NotEmpty(results); @@ -935,9 +935,9 @@ public async Task BulkVSRESTGetPortRequestsAsync() //public async Task Call48GetRatecentersTestAsync() //{ // // Act - // var cred = await Login.LoginAsync(_call48Username, _call48Password).ConfigureAwait(false); + // var cred = await Login.LoginAsync(_call48Username, _call48Password); - // var results = await Ratecenter.GetAllRatecentersAsync(PhoneNumbersNA.AreaCode.States.ToArray(), cred.data.token).ConfigureAwait(false); + // var results = await Ratecenter.GetAllRatecentersAsync(PhoneNumbersNA.AreaCode.States.ToArray(), cred.data.token); // Assert.NotEmpty(results); // output.WriteLine(results.Length.ToString()); @@ -954,20 +954,20 @@ public async Task BulkVSRESTGetPortRequestsAsync() //public async Task Call48PurchaseLocalNumberTestAsync() //{ // // Act - // var cred = await Login.LoginAsync(_call48Username, _call48Password).ConfigureAwait(false); + // var cred = await Login.LoginAsync(_call48Username, _call48Password); - // var results = await Search.GetAsync("WA", 206, cred.data.token).ConfigureAwait(false); + // var results = await Search.GetAsync("WA", 206, cred.data.token); // Assert.NotEmpty(results); // output.WriteLine(results.Count().ToString()); // var number = results.FirstOrDefault(); - // var checkExist = await Search.GetLocalNumbersAsync(string.Empty, number.State, number.NPA.ToString(), number.NXX.ToString(), cred.data.token).ConfigureAwait(false); + // var checkExist = await Search.GetLocalNumbersAsync(string.Empty, number.State, number.NPA.ToString(), number.NXX.ToString(), cred.data.token); // var numberToPurchase = checkExist.data.result.Where(x => x.did.Replace("-", string.Empty) == number.DialedNumber).FirstOrDefault(); // output.WriteLine(JsonSerializer.Serialize(numberToPurchase)); - // var purchaseOrder = await Purchase.PurchasePhoneNumberAsync(checkExist.data.loc, numberToPurchase, cred.data.token).ConfigureAwait(false); + // var purchaseOrder = await Purchase.PurchasePhoneNumberAsync(checkExist.data.loc, numberToPurchase, cred.data.token); // output.WriteLine(JsonSerializer.Serialize(purchaseOrder)); // Assert.NotNull(purchaseOrder); @@ -1093,7 +1093,7 @@ public async Task GetPhoneNumbersByLocationPaginatedAsync() public async Task DeleteOldPhoneNumberAsync() { var conn = postgresql; - var results = await PhoneNumber.DeleteOld(DateTime.Now.AddDays(-3), conn).ConfigureAwait(false); + var results = await PhoneNumber.DeleteOld(DateTime.Now.AddDays(-3), conn); Assert.NotNull(results); output.WriteLine($"{results.Removed} Numbers Removed."); } @@ -1102,7 +1102,7 @@ public async Task DeleteOldPhoneNumberAsync() public async Task DeleteLogsAsync() { var conn = postgresql; - var results = await Logs.DeleteOld(DateTime.Now, conn).ConfigureAwait(false); + var results = await Logs.DeleteOld(DateTime.Now, conn); Assert.NotNull(results); output.WriteLine($"{results.Removed} log entries removed."); } @@ -1113,7 +1113,7 @@ public async Task DeleteOldPhoneNumbersByProviderAsync() var conn = postgresql; var cycle = DateTime.Now.AddHours(1) - DateTime.Now; var provider = "Test"; - var results = await PhoneNumber.DeleteOldByProvider(DateTime.Now, cycle, provider, conn).ConfigureAwait(false); + var results = await PhoneNumber.DeleteOldByProvider(DateTime.Now, cycle, provider, conn); Assert.NotNull(results); output.WriteLine($"{results.Removed} Numbers Removed."); } @@ -1136,11 +1136,11 @@ public async Task PostPhoneNumberAsync() State = "WA" }; - var existing = await PhoneNumber.GetAsync(number.DialedNumber, postgresql).ConfigureAwait(false); + var existing = await PhoneNumber.GetAsync(number.DialedNumber, postgresql); if (existing is not null && existing?.DialedNumber?.Length == 10) { - _ = existing.DeleteAsync(postgresql).ConfigureAwait(false); + _ = existing.DeleteAsync(postgresql); } var response = await number.PostAsync(conn); @@ -1148,7 +1148,7 @@ public async Task PostPhoneNumberAsync() // Clean up. // We need the Guid so we have to get a copy of the new record from the DB before we can delete it. - var fromDb = await PhoneNumber.GetAsync(number.DialedNumber, conn).ConfigureAwait(false); + var fromDb = await PhoneNumber.GetAsync(number.DialedNumber, conn); var checkDelete = await fromDb.DeleteAsync(conn); Assert.True(checkDelete); @@ -1183,10 +1183,10 @@ public async Task PostIngestCyclesAsync() RunNow = true }; - var result = await cycle.PostAsync(postgresql).ConfigureAwait(false); + var result = await cycle.PostAsync(postgresql); Assert.True(result); - var results = await IngestCycle.GetAllAsync(postgresql).ConfigureAwait(false); + var results = await IngestCycle.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); @@ -1194,10 +1194,10 @@ public async Task PostIngestCyclesAsync() Assert.NotNull(test); test.CycleTime = DateTime.Now.AddHours(1) - DateTime.Now; - var checkUpdate = await test.PutAsync(postgresql).ConfigureAwait(false); + var checkUpdate = await test.PutAsync(postgresql); Assert.True(checkUpdate); - results = await IngestCycle.GetAllAsync(postgresql).ConfigureAwait(false); + results = await IngestCycle.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); @@ -1205,7 +1205,7 @@ public async Task PostIngestCyclesAsync() Assert.NotNull(update); //Assert.Equal(test.CycleTime, update.CycleTime); - var checkDelete = await update.DeleteAsync(postgresql).ConfigureAwait(false); + var checkDelete = await update.DeleteAsync(postgresql); Assert.True(checkDelete); } @@ -1231,9 +1231,9 @@ public async Task PostEndOfRunStatsAsync() Assert.True(check); // Clean up. - var fromDb = await IngestStatistics.GetLastIngestAsync(stats.IngestedFrom, conn).ConfigureAwait(false); + var fromDb = await IngestStatistics.GetLastIngestAsync(stats.IngestedFrom, conn); - var checkDelete = await fromDb.DeleteAsync(conn).ConfigureAwait(false); + var checkDelete = await fromDb.DeleteAsync(conn); Assert.True(checkDelete); } @@ -1282,12 +1282,12 @@ public async Task GetPhoneNumbersByAreaCodeAsync() [Fact] public async Task GetVerifiedNumbersAsync() { - var results = await VerifiedPhoneNumber.GetAllAsync(postgresql).ConfigureAwait(false); + var results = await VerifiedPhoneNumber.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); output.WriteLine(JsonSerializer.Serialize(results)); - results = await VerifiedPhoneNumber.GetByOrderIdAsync(results.FirstOrDefault().OrderId ?? Guid.Empty, postgresql).ConfigureAwait(false); + results = await VerifiedPhoneNumber.GetByOrderIdAsync(results.FirstOrDefault().OrderId ?? Guid.Empty, postgresql); Assert.NotNull(results); Assert.NotEmpty(results); } @@ -1324,53 +1324,53 @@ public async Task PostPutDeleteVerifiedNumbersAsync() Wireless = true }; - var checkPost = await testNumber.PostAsync(postgresql).ConfigureAwait(false); + var checkPost = await testNumber.PostAsync(postgresql); Assert.True(checkPost); - var checkSave = await VerifiedPhoneNumber.GetByOrderIdAsync(testNumber.OrderId ?? Guid.Empty, postgresql).ConfigureAwait(false); + var checkSave = await VerifiedPhoneNumber.GetByOrderIdAsync(testNumber.OrderId ?? Guid.Empty, postgresql); Assert.True(checkSave.FirstOrDefault().VerifiedDialedNumber == testNumber.VerifiedDialedNumber); testNumber.LocalAccessTransportArea = "testtest"; - var checkPut = await testNumber.PutAsync(postgresql).ConfigureAwait(false); + var checkPut = await testNumber.PutAsync(postgresql); Assert.True(checkPut); - checkSave = await VerifiedPhoneNumber.GetByOrderIdAsync(testNumber.OrderId ?? Guid.Empty, postgresql).ConfigureAwait(false); + checkSave = await VerifiedPhoneNumber.GetByOrderIdAsync(testNumber.OrderId ?? Guid.Empty, postgresql); Assert.True(checkSave.FirstOrDefault().LocalAccessTransportArea == testNumber.LocalAccessTransportArea); - var checkDelete = await testNumber.DeleteAsync(postgresql).ConfigureAwait(false); + var checkDelete = await testNumber.DeleteAsync(postgresql); Assert.True(checkDelete); } [Fact] public async Task GetAllPortedPhoneNumbersAsync() { - var results = await PortedPhoneNumber.GetAllAsync(postgresql).ConfigureAwait(false); + var results = await PortedPhoneNumber.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); output.WriteLine(JsonSerializer.Serialize(results.LastOrDefault())); var order = results.LastOrDefault(); - results = await PortedPhoneNumber.GetByOrderIdAsync(order.OrderId ?? Guid.Empty, postgresql).ConfigureAwait(false); + results = await PortedPhoneNumber.GetByOrderIdAsync(order.OrderId ?? Guid.Empty, postgresql); Assert.NotNull(results); Assert.NotEmpty(results); output.WriteLine(JsonSerializer.Serialize(results)); - //results = await PortedPhoneNumber.GetByPortRequestIdAsync(order.PortRequestId ?? Guid.Empty, postgresql).ConfigureAwait(false); + //results = await PortedPhoneNumber.GetByPortRequestIdAsync(order.PortRequestId ?? Guid.Empty, postgresql); //Assert.NotNull(results); //Assert.NotEmpty(results); //output.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(results)); - results = await PortedPhoneNumber.GetByDialedNumberAsync(order.PortedDialedNumber, postgresql).ConfigureAwait(false); + results = await PortedPhoneNumber.GetByDialedNumberAsync(order.PortedDialedNumber, postgresql); Assert.NotNull(results); Assert.NotEmpty(results); output.WriteLine(JsonSerializer.Serialize(results)); - results = await PortedPhoneNumber.GetByExternalIdAsync(order.ExternalPortRequestId, postgresql).ConfigureAwait(false); + results = await PortedPhoneNumber.GetByExternalIdAsync(order.ExternalPortRequestId, postgresql); Assert.NotNull(results); //Assert.NotEmpty(results); output.WriteLine(JsonSerializer.Serialize(results)); - var result = await PortedPhoneNumber.GetByIdAsync(order.PortedPhoneNumberId, postgresql).ConfigureAwait(false); + var result = await PortedPhoneNumber.GetByIdAsync(order.PortedPhoneNumberId, postgresql); Assert.NotNull(result); output.WriteLine(JsonSerializer.Serialize(result)); } @@ -1397,31 +1397,31 @@ public async Task PostPutDeletePortedPhoneNumberAsync() Wireless = false }; - var checkPost = await ported.PostAsync(postgresql).ConfigureAwait(false); + var checkPost = await ported.PostAsync(postgresql); Assert.True(checkPost); - var verifyPost = await PortedPhoneNumber.GetByOrderIdAsync(ported.OrderId ?? Guid.Empty, postgresql).ConfigureAwait(false); + var verifyPost = await PortedPhoneNumber.GetByOrderIdAsync(ported.OrderId ?? Guid.Empty, postgresql); Assert.NotNull(verifyPost); Assert.NotEmpty(verifyPost); var verified = verifyPost.FirstOrDefault(); Assert.True(ported.OrderId == verified.OrderId); verified.ExternalPortRequestId = "testtest"; - var checkPut = await verified.PutAsync(postgresql).ConfigureAwait(false); + var checkPut = await verified.PutAsync(postgresql); Assert.True(checkPut); - var verifyPut = await PortedPhoneNumber.GetByIdAsync(verified.PortedPhoneNumberId, postgresql).ConfigureAwait(false); + var verifyPut = await PortedPhoneNumber.GetByIdAsync(verified.PortedPhoneNumberId, postgresql); Assert.NotNull(verifyPut); Assert.True(verifyPut.ExternalPortRequestId == verified.ExternalPortRequestId); - var checkDelete = await verifyPut.DeleteAsync(postgresql).ConfigureAwait(false); + var checkDelete = await verifyPut.DeleteAsync(postgresql); Assert.True(checkDelete); } [Fact] public async Task GetAllPortRequestsAsync() { - var results = await PortRequest.GetAllAsync(postgresql).ConfigureAwait(false); + var results = await PortRequest.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); output.WriteLine(JsonSerializer.Serialize(results)); @@ -1430,59 +1430,59 @@ public async Task GetAllPortRequestsAsync() [Fact] public async Task GetPortRequestByOrderIdAsync() { - var results = await PortRequest.GetAllAsync(postgresql).ConfigureAwait(false); + var results = await PortRequest.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); - var order = await PortRequest.GetByOrderIdAsync(results.FirstOrDefault().OrderId, postgresql).ConfigureAwait(false); + var order = await PortRequest.GetByOrderIdAsync(results.FirstOrDefault().OrderId, postgresql); output.WriteLine(JsonSerializer.Serialize(order)); } [Fact] public async Task GetPostPutDeletePortRequestByOrderIdAsync() { - var results = await PortRequest.GetAllAsync(postgresql).ConfigureAwait(false); + var results = await PortRequest.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); - var portRequest = await PortRequest.GetByOrderIdAsync(results.FirstOrDefault().OrderId, postgresql).ConfigureAwait(false); + var portRequest = await PortRequest.GetByOrderIdAsync(results.FirstOrDefault().OrderId, postgresql); output.WriteLine(JsonSerializer.Serialize(portRequest)); portRequest.PortRequestId = Guid.NewGuid(); - var checkCreate = await portRequest.PostAsync(postgresql).ConfigureAwait(false); + var checkCreate = await portRequest.PostAsync(postgresql); Assert.True(checkCreate); portRequest.ProviderPIN = "1234"; - var checkUpdate = await portRequest.PutAsync(postgresql).ConfigureAwait(false); + var checkUpdate = await portRequest.PutAsync(postgresql); Assert.True(checkUpdate); - var checkDelete = await portRequest.DeleteByIdAsync(postgresql).ConfigureAwait(false); + var checkDelete = await portRequest.DeleteByIdAsync(postgresql); Assert.True(checkDelete); } [Fact] public async Task GetPostPutDeleteCouponsAsync() { - var results = await Coupon.GetAllAsync(postgresql).ConfigureAwait(false); + var results = await Coupon.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); - var result = await Coupon.GetByIdAsync(results.FirstOrDefault().CouponId, postgresql).ConfigureAwait(false); + var result = await Coupon.GetByIdAsync(results.FirstOrDefault().CouponId, postgresql); Assert.NotNull(result); Assert.True(results?.FirstOrDefault()?.CouponId == result?.CouponId); result.CouponId = Guid.NewGuid(); result.Name = "Test"; result.Description = "Test"; result.Public = false; - var checkCreate = await result.PostAsync(postgresql).ConfigureAwait(false); + var checkCreate = await result.PostAsync(postgresql); Assert.True(checkCreate); - result = await Coupon.GetByIdAsync(result.CouponId, postgresql).ConfigureAwait(false); + result = await Coupon.GetByIdAsync(result.CouponId, postgresql); Assert.NotNull(result); result.Name = "Test2"; - var checkUpdate = await result.PutAsync(postgresql).ConfigureAwait(false); + var checkUpdate = await result.PutAsync(postgresql); Assert.True(checkUpdate); - var checkDelete = await result.DeleteAsync(postgresql).ConfigureAwait(false); + var checkDelete = await result.DeleteAsync(postgresql); Assert.True(checkDelete); } [Fact] public async Task GetAllSentEmailsAsync() { - var results = await Email.GetAllAsync(postgresql).ConfigureAwait(false); + var results = await Email.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); } @@ -1490,13 +1490,13 @@ public async Task GetAllSentEmailsAsync() [Fact] public async Task GetSentEmailByIdAsync() { - var results = await Email.GetAllAsync(postgresql).ConfigureAwait(false); + var results = await Email.GetAllAsync(postgresql); Assert.NotNull(results); Assert.NotEmpty(results); var email = results.FirstOrDefault(); - var result = await Email.GetAsync(email.EmailId, postgresql).ConfigureAwait(false); + var result = await Email.GetAsync(email.EmailId, postgresql); Assert.NotNull(result); Assert.Equal(email.EmailId, result.EmailId); } @@ -1536,11 +1536,11 @@ public async Task PostSentEmailAsync() }; - var checkSubmit = await email.PostAsync(postgresql).ConfigureAwait(false); + var checkSubmit = await email.PostAsync(postgresql); Assert.True(checkSubmit); // Clean up - var fromDb = await Email.GetByOrderAsync(email.OrderId, postgresql).ConfigureAwait(false); + var fromDb = await Email.GetByOrderAsync(email.OrderId, postgresql); Assert.NotNull(fromDb); Assert.NotEmpty(fromDb); foreach (var item in fromDb) @@ -1553,10 +1553,10 @@ public async Task PostSentEmailAsync() item.DateSent = DateTime.Now; item.Completed = true; - var checkUpdate = await item.PutAsync(postgresql).ConfigureAwait(false); + var checkUpdate = await item.PutAsync(postgresql); Assert.True(checkUpdate); - var updatedDb = await Email.GetAsync(item.EmailId, postgresql).ConfigureAwait(false); + var updatedDb = await Email.GetAsync(item.EmailId, postgresql); Assert.NotNull(updatedDb); Assert.Equal(updatedDb.PrimaryEmailAddress, item.PrimaryEmailAddress); Assert.Equal(updatedDb.Subject, item.Subject); @@ -1565,7 +1565,7 @@ public async Task PostSentEmailAsync() Assert.Equal(updatedDb.Completed, item.Completed); Assert.True(updatedDb.Completed); - var checkDelete = await updatedDb.DeleteAsync(postgresql).ConfigureAwait(false); + var checkDelete = await updatedDb.DeleteAsync(postgresql); Assert.True(checkDelete); } } @@ -1575,7 +1575,7 @@ public async Task GetOrderAsync() { var conn = postgresql; - var results = await Order.GetAllAsync(conn).ConfigureAwait(false); + var results = await Order.GetAllAsync(conn); Assert.NotNull(results); Assert.NotEmpty(results); @@ -1593,7 +1593,7 @@ public async Task GetOrderAsync() Assert.True(result.DateSubmitted > new DateTime(2019, 1, 1)); } - var quotes = await Order.GetAllQuotesAsync(conn).ConfigureAwait(false); + var quotes = await Order.GetAllQuotesAsync(conn); Assert.NotNull(quotes); Assert.NotEmpty(quotes); @@ -1605,7 +1605,7 @@ public async Task GetOrderByBackGroundworkNotCompletedAsync() { var conn = postgresql; - var results = await Order.GetByBackGroundworkNotCompletedAsync(conn).ConfigureAwait(false); + var results = await Order.GetByBackGroundworkNotCompletedAsync(conn); Assert.NotNull(results); } @@ -1615,14 +1615,14 @@ public async Task GetOrderByBackGroundworkNotCompletedAsync() //{ // var conn = postgresql; - // var results = await Order.GetAllAsync(conn).ConfigureAwait(false); + // var results = await Order.GetAllAsync(conn); // Assert.NotNull(results); // Assert.NotEmpty(results); // var order = results.FirstOrDefault(); - // var taxrate = await SalesTax.GetTaxRateAsync(order.Address, order.City, order.Zip).ConfigureAwait(false); + // var taxrate = await SalesTax.GetTaxRateAsync(order.Address, order.City, order.Zip); // Assert.True(taxrate > 0.0M); // output.WriteLine($"Taxrate: {taxrate}"); @@ -1635,7 +1635,7 @@ public async Task GetRawSaleTaxInfoAsync() string city = string.Empty; string zip = "98501"; - var result = await SalesTax.GetLocalAPIAsync(address, city, zip).ConfigureAwait(false); + var result = await SalesTax.GetLocalAPIAsync(address, city, zip); Assert.NotNull(result); Assert.True(result.rate1 > 0.0M); @@ -1647,7 +1647,7 @@ public async Task PostOrderAsync() { var conn = postgresql; - var orders = await Order.GetAllAsync(conn).ConfigureAwait(false); + var orders = await Order.GetAllAsync(conn); var selectedOrders = orders.Where(x => x.OrderId != Guid.Empty).FirstOrDefault(); Assert.False(selectedOrders is null); @@ -1666,7 +1666,7 @@ public async Task PostOrderAsync() Assert.False(fromDb is null); - var checkDelete = await fromDb.DeleteAsync(conn).ConfigureAwait(false); + var checkDelete = await fromDb.DeleteAsync(conn); Assert.True(checkDelete); } @@ -1687,11 +1687,11 @@ public async Task PostProductOrderByProductIdAsync() Assert.True(result); // Clean up. - var fromDb = await ProductOrder.GetAsync(itemToOrder.OrderId, conn).ConfigureAwait(false); + var fromDb = await ProductOrder.GetAsync(itemToOrder.OrderId, conn); Assert.NotNull(fromDb); Assert.NotEmpty(fromDb); - var checkDelete = await fromDb.FirstOrDefault().DeleteByOrderAsync(conn).ConfigureAwait(false); + var checkDelete = await fromDb.FirstOrDefault().DeleteByOrderAsync(conn); Assert.True(checkDelete); } @@ -1713,11 +1713,11 @@ public async Task PostProductOrderByDialedNumberAsync() Assert.True(result); // Clean up. - var fromDb = await ProductOrder.GetAsync(itemToOrder.OrderId, conn).ConfigureAwait(false); + var fromDb = await ProductOrder.GetAsync(itemToOrder.OrderId, conn); Assert.NotNull(fromDb); Assert.NotEmpty(fromDb); - var checkDelete = await fromDb.FirstOrDefault().DeleteByOrderAsync(conn).ConfigureAwait(false); + var checkDelete = await fromDb.FirstOrDefault().DeleteByOrderAsync(conn); Assert.True(checkDelete); } @@ -1741,10 +1741,10 @@ public async Task PostPurchasedPhoneNumberAsync() Assert.True(result); // Clean up. - var fromDb = await PurchasedPhoneNumber.GetByDialedNumberAndOrderIdAsync(itemToOrder.DialedNumber, itemToOrder.OrderId, conn).ConfigureAwait(false); + var fromDb = await PurchasedPhoneNumber.GetByDialedNumberAndOrderIdAsync(itemToOrder.DialedNumber, itemToOrder.OrderId, conn); Assert.NotNull(fromDb); - var checkDelete = await fromDb.DeleteAsync(conn).ConfigureAwait(false); + var checkDelete = await fromDb.DeleteAsync(conn); Assert.True(checkDelete); } @@ -1753,11 +1753,11 @@ public async Task GetEmergencyInfoAsync() { var conn = postgresql; - var results = await EmergencyInformation.GetAllAsync(conn).ConfigureAwait(false); + var results = await EmergencyInformation.GetAllAsync(conn); Assert.NotNull(results); Assert.NotEmpty(results); - var result = await EmergencyInformation.GetByDialedNumberAsync(results.FirstOrDefault().DialedNumber, conn).ConfigureAwait(false); + var result = await EmergencyInformation.GetByDialedNumberAsync(results.FirstOrDefault().DialedNumber, conn); Assert.NotNull(result); Assert.NotEmpty(results); Assert.Equal(results.FirstOrDefault().DialedNumber, result.FirstOrDefault().DialedNumber); @@ -1790,13 +1790,13 @@ public async Task PostPutDeleteEmergencyInfoAsync() Assert.True(result); // Clean up. - var fromDbResult = await EmergencyInformation.GetByIdAsync(info.EmergencyInformationId, conn).ConfigureAwait(false); + var fromDbResult = await EmergencyInformation.GetByIdAsync(info.EmergencyInformationId, conn); Assert.NotNull(fromDbResult); Assert.True(info.IngestedFrom == fromDbResult.IngestedFrom); fromDbResult.CallerName = "Test2"; - var checkUpdate = await fromDbResult.PutAsync(conn).ConfigureAwait(false); + var checkUpdate = await fromDbResult.PutAsync(conn); Assert.True(checkUpdate); - var checkDelete = await fromDbResult.DeleteAsync(conn).ConfigureAwait(false); + var checkDelete = await fromDbResult.DeleteAsync(conn); Assert.True(checkDelete); } @@ -1816,11 +1816,11 @@ public async Task GetProductOrderAsync() }; - var result = await itemToOrder.PostAsync(conn).ConfigureAwait(false); + var result = await itemToOrder.PostAsync(conn); Assert.True(result); // Act - var results = await ProductOrder.GetAsync(itemToOrder.OrderId, conn).ConfigureAwait(false); + var results = await ProductOrder.GetAsync(itemToOrder.OrderId, conn); // Assert Assert.NotNull(results); @@ -1831,7 +1831,7 @@ public async Task GetProductOrderAsync() } // Clean up. - var checkDelete = await results.FirstOrDefault().DeleteByOrderAsync(conn).ConfigureAwait(false); + var checkDelete = await results.FirstOrDefault().DeleteByOrderAsync(conn); Assert.True(checkDelete); } @@ -1855,7 +1855,7 @@ public async Task OwnedPhoneNumberCRUDAsync() }; // Act - var checkCreate = await ownedPhoneNumber.PostAsync(postgresql).ConfigureAwait(false); + var checkCreate = await ownedPhoneNumber.PostAsync(postgresql); Assert.True(checkCreate); @@ -1863,7 +1863,7 @@ public async Task OwnedPhoneNumberCRUDAsync() Assert.NotNull(fromDb); fromDb.Notes = "IntegrationTest"; - var checkUpdate = await fromDb.PutAsync(postgresql).ConfigureAwait(false); + var checkUpdate = await fromDb.PutAsync(postgresql); Assert.True(checkUpdate); var fromDbAgain = await OwnedPhoneNumber.GetByDialedNumberAsync(ownedPhoneNumber.DialedNumber, conn); @@ -1875,7 +1875,7 @@ public async Task OwnedPhoneNumberCRUDAsync() Assert.Equal(fromDb.OwnedPhoneNumberId, fromDbAgain.OwnedPhoneNumberId); // Clean up - var checkDelete = await fromDbAgain.DeleteAsync(postgresql).ConfigureAwait(false); + var checkDelete = await fromDbAgain.DeleteAsync(postgresql); Assert.True(checkDelete); } @@ -1930,15 +1930,15 @@ public async Task GetLockAsync() Lock = true }; - var checkLock = await lockingStats.PostAsync(conn).ConfigureAwait(false); + var checkLock = await lockingStats.PostAsync(conn); Assert.True(checkLock); - var results = await IngestStatistics.GetLockAsync("Test", conn).ConfigureAwait(false); + var results = await IngestStatistics.GetLockAsync("Test", conn); Assert.NotNull(results); - var checkRemoveLock = await results.DeleteAsync(conn).ConfigureAwait(false); + var checkRemoveLock = await results.DeleteAsync(conn); Assert.True(checkRemoveLock); }