diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs index 712719e23..68d4ad649 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs @@ -18,11 +18,11 @@ public class CatalogContextSeed { - public async Task SeedAsync(CatalogContext context,IHostingEnvironment env,IOptions settings,ILogger logger) + public Task SeedAsync(CatalogContext context,IHostingEnvironment env,IOptions settings,ILogger logger) { var policy = CreatePolicy(logger, nameof(CatalogContextSeed)); - await policy.ExecuteAsync(async () => + return policy.ExecuteAsync(async () => { var useCustomizationData = settings.Value.UseCustomizationData; var contentRootPath = env.ContentRootPath; diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs index 1b82251e3..fde8b87a6 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs @@ -27,18 +27,18 @@ namespace Catalog.API.IntegrationEvents _eventLogService = _integrationEventLogServiceFactory(_catalogContext.Database.GetDbConnection()); } - public async Task PublishThroughEventBusAsync(IntegrationEvent evt) + public Task PublishThroughEventBusAsync(IntegrationEvent evt) { _eventBus.Publish(evt); - await _eventLogService.MarkEventAsPublishedAsync(evt); + return _eventLogService.MarkEventAsPublishedAsync(evt); } - public async Task SaveEventAndCatalogContextChangesAsync(IntegrationEvent evt) + public Task SaveEventAndCatalogContextChangesAsync(IntegrationEvent evt) { //Use of an EF Core resiliency strategy when using multiple DbContexts within an explicit BeginTransaction(): //See: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency - await ResilientTransaction.New(_catalogContext) + return ResilientTransaction.New(_catalogContext) .ExecuteAsync(async () => { // Achieving atomicity between original catalog database operation and the IntegrationEventLog thanks to a local transaction await _catalogContext.SaveChangesAsync(); diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs index 0f30a3e0a..ac2901ef9 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs @@ -28,7 +28,7 @@ foreach (var orderStockItem in command.OrderStockItems) { - var catalogItem = _catalogContext.CatalogItems.Find(orderStockItem.ProductId); + var catalogItem = await _catalogContext.CatalogItems.FindAsync(orderStockItem.ProductId); var hasStock = catalogItem.AvailableStock >= orderStockItem.Units; var confirmedOrderStockItem = new ConfirmedOrderStockItem(catalogItem.Id, hasStock); diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs index 0a45547f9..d2daa9ba9 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs @@ -15,7 +15,7 @@ _catalogContext = catalogContext; } - public async Task Handle(OrderStatusChangedToPaidIntegrationEvent command) + public Task Handle(OrderStatusChangedToPaidIntegrationEvent command) { //we're not blocking stock/inventory foreach (var orderStockItem in command.OrderStockItems) @@ -25,7 +25,7 @@ catalogItem.RemoveStock(orderStockItem.Units); } - await _catalogContext.SaveChangesAsync(); + return _catalogContext.SaveChangesAsync(); } } } \ No newline at end of file