From f5c1af153558ddeb8510d49f02fd5c9afb94f864 Mon Sep 17 00:00:00 2001 From: Sumit Ghosh Date: Thu, 21 Oct 2021 19:09:11 +0530 Subject: [PATCH] Fixes few bugs in Net 6.0 service migration (#1774) * Created global using file for catalog.api * Moved individual usings statements to globalusing * Updated catalog.api project * Fixed local run bug for catalog.api * Included globalusing for payment.api * Refactored namespace statement for payment.api * Moved namespaces to ordering.domain project * Included globalusing for ordering.domain project * Included globalusings for ordering.infrastructure project * Refactored namespaces for ordering.infrastructure project * Updated relevant packages in ordering.infrastructure project * Included globalusings for ordering.signalrHub project * Moved all the namespace to globalusings * Updated packages in ordering.signalrHub csproj file * Refactored namespace statements in catalog.api project * Fixed namespace name in ordering.domain * Included global usings for ordering.api project * Moved all usings to globalusing file * Updated ordering.api csproj project * Fixed bug in statup.cs * Updated ordering.unittests.csproj file * Included globalusings in webhooks.api project * Moved using statements to globalusing file in webhooks.api * Included globalusing for web.bff.shoppping aggregator project * Moved namespaces to globalusing shopping aggregator * Included globalusing mobile.bff.shoppping project * Moved namespaces to globalusing file * Included globalusing for eventbus project * Moved namespaces to global usings for eventbus * Included globalusing for EventBusRabbitMQ project * Moved using statements to EventBusRabbitMQ project * Included global using in EventBusServiceBus project * Moved using statements to globalusing for EventBusServiceBus * Included globalusing file for IntegrationEventLogEF project * Move using statements to globalusing file * Updated packages of IntegrationEventLogEF project * Included globalusing to Devspaces.Support project * Moved using statements to globalusing Devspaces * Updated dependent packages for Devspaces.Support.csproj * Fixed bug in Basket API * Fixed bug in catalog.api * Fixed bug Identity.API * Included globalusing to Basket.UnitTest project * Moved namespaces to Basket.UnitTest project * Updated packages of Basket.UnitTest csproj * Included globalusing for Basket.FunctionalTests project * Included file-scoped namespaces Basket.FunctionalTests * Updated packages of Basket.FunctionalTests.csproj file * Updated catalog unit test project to Net 6.0 * Included global usings for Catalog.FunctionalTests * Included file-scope namespace catalog.functionaltests * Updated packages of catalog.functionaltest csproj * Included MigrateDbContext method in HostExtensions * Included globalusing for ordering.UnitTests project * Included file-scope statement for Ordering.UnitTest project * Included globalusing for Ordering.FunctionalTests * Included file-scope namespace statement for using * Updated packages in Ordering.FunctionalTests.csproj * Apply suggestions from code review Co-authored-by: David Pine * Apply suggestions from code review Co-authored-by: David Pine * Update src/Services/Ordering/Ordering.API/Startup.cs Co-authored-by: David Pine * Update src/Services/Ordering/Ordering.Domain/Events/OrderStatusChangedToPaidDomainEvent.cs Co-authored-by: David Pine * Update src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs Co-authored-by: David Pine * Update src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs Co-authored-by: David Pine * Apply suggestions from code review Co-authored-by: David Pine * Apply suggestions from code review Co-authored-by: David Pine * Fixed bugs in Mobile.BFF.Shopping project * Fixed bugs in Web.Bff.Shopping aggregator project * Fixed bugs in EventBusServiceBus project * Fixed bug in Mobile.Bff.Shopping project Co-authored-by: David Pine --- .../aggregator/Controllers/BasketController.cs | 7 +++---- .../aggregator/Controllers/OrderController.cs | 2 +- .../aggregator/Services/BasketService.cs | 2 +- .../aggregator/Controllers/BasketController.cs | 2 +- .../aggregator/Controllers/OrderController.cs | 2 +- .../HttpClientAuthorizationDelegatingHandler.cs | 2 +- .../Web.Bff.Shopping/aggregator/Services/BasketService.cs | 5 ++--- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/BasketController.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/BasketController.cs index 9f39cdd6d..a3cf4f03c 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/BasketController.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/BasketController.cs @@ -26,8 +26,7 @@ public class BasketController : ControllerBase } // Retrieve the current basket - var basket = await _basket.GetById(data.BuyerId) ?? new BasketData(data.BuyerId); - + var basket = await _basket.GetByIdAsync(data.BuyerId) ?? new BasketData(data.BuyerId); var catalogItems = await _catalog.GetCatalogItemsAsync(data.Items.Select(x => x.ProductId)); // group by product id to avoid duplicates var itemsCalculated = data @@ -84,7 +83,7 @@ public class BasketController : ControllerBase } // Retrieve the current basket - var currentBasket = await _basket.GetById(data.BasketId); + var currentBasket = await _basket.GetByIdAsync(data.BasketId); if (currentBasket == null) { return BadRequest($"Basket with id {data.BasketId} not found."); @@ -126,7 +125,7 @@ public class BasketController : ControllerBase //item.PictureUri = // Step 2: Get current basket status - var currentBasket = (await _basket.GetById(data.BasketId)) ?? new BasketData(data.BasketId); + var currentBasket = (await _basket.GetByIdAsync(data.BasketId)) ?? new BasketData(data.BasketId); // Step 3: Merge current status with new product currentBasket.Items.Add(new BasketDataItem() { diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/OrderController.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/OrderController.cs index 2203db664..55b4dd70b 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/OrderController.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Controllers/OrderController.cs @@ -25,7 +25,7 @@ public class OrderController : ControllerBase return BadRequest("Need a valid basketid"); } // Get the basket data and build a order draft based on it - var basket = await _basketService.GetById(basketId); + var basket = await _basketService.GetByIdAsync(basketId); if (basket == null) { diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/BasketService.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/BasketService.cs index 1b081bf85..b9fed393f 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/BasketService.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/BasketService.cs @@ -11,7 +11,7 @@ public class BasketService : IBasketService _logger = logger; } - public async Task GetById(string id) + public async Task GetByIdAsync(string id) { _logger.LogDebug("grpc client created, request = {@id}", id); var response = await _basketClient.GetBasketByIdAsync(new BasketRequest { Id = id }); diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs index 008ded21b..143ff9a2b 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/BasketController.cs @@ -124,7 +124,7 @@ public class BasketController : ControllerBase //item.PictureUri = // Step 2: Get current basket status - var currentBasket = (await _basket.GetById(data.BasketId)) ?? new BasketData(data.BasketId); + var currentBasket = (await _basket.GetByIdAsync(data.BasketId)) ?? new BasketData(data.BasketId); // Step 3: Search if exist product into basket var product = currentBasket.Items.SingleOrDefault(i => i.ProductId == item.Id); if (product != null) diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/OrderController.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/OrderController.cs index 5897a5c86..448bbec85 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/OrderController.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Controllers/OrderController.cs @@ -20,7 +20,7 @@ public class OrderController : ControllerBase [ProducesResponseType(typeof(OrderData), (int)HttpStatusCode.OK)] public async Task> GetOrderDraftAsync(string basketId) { - if (string.IsNullOrWhitespace(basketId)) + if (string.IsNullOrWhiteSpace(basketId)) { return BadRequest("Need a valid basketid"); } diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Infrastructure/HttpClientAuthorizationDelegatingHandler.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Infrastructure/HttpClientAuthorizationDelegatingHandler.cs index a024560c6..d9b3b0ee1 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Infrastructure/HttpClientAuthorizationDelegatingHandler.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Infrastructure/HttpClientAuthorizationDelegatingHandler.cs @@ -15,7 +15,7 @@ public class HttpClientAuthorizationDelegatingHandler var authorizationHeader = _httpContextAccessor.HttpContext .Request.Headers["Authorization"]; - if (!string.IsNullOrWhitespace(authorizationHeader)) + if (!string.IsNullOrWhiteSpace(authorizationHeader)) { request.Headers.Add("Authorization", new List() { authorizationHeader }); } diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/BasketService.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/BasketService.cs index 64feecfa2..41d14d450 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/BasketService.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/BasketService.cs @@ -10,9 +10,8 @@ public class BasketService : IBasketService _basketClient = basketClient; _logger = logger; } - - - public async Task GetById(string id) + + public async Task GetByIdAsync(string id) { _logger.LogDebug("grpc client created, request = {@id}", id); var response = await _basketClient.GetBasketByIdAsync(new BasketRequest { Id = id });