From 0ee173cd34e095432d4aca05c9b13d78d833cf7e Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Wed, 17 May 2017 11:57:02 +0200 Subject: [PATCH] naming changes --- ...ler.cs => ConfirmOrderStockCommandHandler.cs} | 14 +++++++------- ...r.cs => DecrementOrderStockCommandHandler.cs} | 8 ++++---- ...CommandMsg.cs => ConfirmOrderStockCommand.cs} | 4 ++-- ...mmandMsg.cs => DecrementOrderStockCommand.cs} | 4 ++-- .../OrderStockNotConfirmedIntegrationEvent.cs | 6 +++--- src/Services/Catalog/Catalog.API/Startup.cs | 12 ++++++------ ...ngedToAwaitingValidationDomainEventHandler.cs | 6 +++--- ...OrderStatusChangedToPaidDomainEventHandler.cs | 6 +++--- ...sChangedToStockConfirmedDomainEventHandler.cs | 6 +++--- ...ommandMsg.cs => ConfirmGracePeriodCommand.cs} | 4 ++-- ...CommandMsg.cs => ConfirmOrderStockCommand.cs} | 4 ++-- ...mmandMsg.cs => DecrementOrderStockCommand.cs} | 4 ++-- ...{PayOrderCommandMsg.cs => PayOrderCommand.cs} | 4 ++-- .../Commands/ShipOrderCommandMsg.cs | 14 -------------- ...erStockNotConfirmedIntegrationEventHandler.cs | 2 +- .../OrderStockNotConfirmedIntegrationEvent.cs | 6 +++--- .../Application/Sagas/OrderProcessSaga.cs | 4 ++-- src/Services/Ordering/Ordering.API/Startup.cs | 4 ++-- ...ndMsgHandler.cs => PayOrderCommandHandler.cs} | 14 +++++--------- ...{PayOrderCommandMsg.cs => PayOrderCommand.cs} | 4 ++-- src/Services/Payment/Payment.API/Startup.cs | 16 +++++++++++----- ...ommandMsg.cs => ConfirmGracePeriodCommand.cs} | 4 ++-- src/Services/SagaManager/SagaManager/Program.cs | 2 +- .../SagaManager/Services/ISagaManagerService.cs | 2 +- .../SagaManager/Services/SagaManagerService.cs | 9 ++++----- 25 files changed, 75 insertions(+), 88 deletions(-) rename src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/{ConfirmOrderStockCommandMsgHandler.cs => ConfirmOrderStockCommandHandler.cs} (80%) rename src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/{DecrementOrderStockCommandMsgHandler.cs => DecrementOrderStockCommandHandler.cs} (66%) rename src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/{ConfirmOrderStockCommandMsg.cs => ConfirmOrderStockCommand.cs} (85%) rename src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/{DecrementOrderStockCommandMsg.cs => DecrementOrderStockCommand.cs} (79%) rename src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/{ConfirmGracePeriodCommandMsg.cs => ConfirmGracePeriodCommand.cs} (63%) rename src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/{ConfirmOrderStockCommandMsg.cs => ConfirmOrderStockCommand.cs} (85%) rename src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/{DecrementOrderStockCommandMsg.cs => DecrementOrderStockCommand.cs} (78%) rename src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/{PayOrderCommandMsg.cs => PayOrderCommand.cs} (69%) delete mode 100644 src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ShipOrderCommandMsg.cs rename src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/{PayOrderCommandMsgHandler.cs => PayOrderCommandHandler.cs} (71%) rename src/Services/Payment/Payment.API/IntegrationCommands/Commands/{PayOrderCommandMsg.cs => PayOrderCommand.cs} (58%) rename src/Services/SagaManager/SagaManager/IntegrationEvents/Events/{ConfirmGracePeriodCommandMsg.cs => ConfirmGracePeriodCommand.cs} (54%) diff --git a/src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/ConfirmOrderStockCommandMsgHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/ConfirmOrderStockCommandHandler.cs similarity index 80% rename from src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/ConfirmOrderStockCommandMsgHandler.cs rename to src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/ConfirmOrderStockCommandHandler.cs index beb23bbaf..7edfd5cf7 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/ConfirmOrderStockCommandMsgHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/ConfirmOrderStockCommandHandler.cs @@ -12,23 +12,23 @@ using Commands; using IntegrationEvents.Events; - public class ConfirmOrderStockCommandMsgHandler : IIntegrationEventHandler + public class ConfirmOrderStockCommandHandler : IIntegrationEventHandler { private readonly CatalogContext _catalogContext; private readonly ICatalogIntegrationEventService _catalogIntegrationEventService; - public ConfirmOrderStockCommandMsgHandler(CatalogContext catalogContext, + public ConfirmOrderStockCommandHandler(CatalogContext catalogContext, ICatalogIntegrationEventService catalogIntegrationEventService) { _catalogContext = catalogContext; _catalogIntegrationEventService = catalogIntegrationEventService; } - public async Task Handle(ConfirmOrderStockCommandMsg @event) + public async Task Handle(ConfirmOrderStockCommand command) { var confirmedOrderStockItems = new List(); - foreach (var orderStockItem in @event.OrderStockItems) + foreach (var orderStockItem in command.OrderStockItems) { var catalogItem = _catalogContext.CatalogItems.Find(orderStockItem.ProductId); CheckValidcatalogItemId(catalogItem); @@ -39,9 +39,9 @@ confirmedOrderStockItems.Add(confirmedOrderStockItem); } - var confirmedIntegrationEvent = confirmedOrderStockItems.Any(c => !c.Confirmed) - ? (IntegrationEvent) new OrderStockNotConfirmedIntegrationEvent(@event.OrderId, confirmedOrderStockItems) - : new OrderStockConfirmedIntegrationEvent(@event.OrderId); + var confirmedIntegrationEvent = confirmedOrderStockItems.Any(c => !c.HasStock) + ? (IntegrationEvent) new OrderStockNotConfirmedIntegrationEvent(command.OrderId, confirmedOrderStockItems) + : new OrderStockConfirmedIntegrationEvent(command.OrderId); await _catalogIntegrationEventService.SaveEventAndCatalogContextChangesAsync(confirmedIntegrationEvent); await _catalogIntegrationEventService.PublishThroughEventBusAsync(confirmedIntegrationEvent); diff --git a/src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandMsgHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandHandler.cs similarity index 66% rename from src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandMsgHandler.cs rename to src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandHandler.cs index a6bc43228..1c7d1b9a3 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandMsgHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandHandler.cs @@ -5,19 +5,19 @@ using Infrastructure; using Commands; - public class DecrementOrderStockCommandMsgHandler : IIntegrationEventHandler + public class DecrementOrderStockCommandHandler : IIntegrationEventHandler { private readonly CatalogContext _catalogContext; - public DecrementOrderStockCommandMsgHandler(CatalogContext catalogContext) + public DecrementOrderStockCommandHandler(CatalogContext catalogContext) { _catalogContext = catalogContext; } - public async Task Handle(DecrementOrderStockCommandMsg @event) + public async Task Handle(DecrementOrderStockCommand command) { //we're not blocking stock/inventory - foreach (var orderStockItem in @event.OrderStockItems) + foreach (var orderStockItem in command.OrderStockItems) { var catalogItem = _catalogContext.CatalogItems.Find(orderStockItem.ProductId); diff --git a/src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/ConfirmOrderStockCommandMsg.cs b/src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs similarity index 85% rename from src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/ConfirmOrderStockCommandMsg.cs rename to src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs index f5fc805b2..2c5296776 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/ConfirmOrderStockCommandMsg.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs @@ -3,12 +3,12 @@ using BuildingBlocks.EventBus.Events; using System.Collections.Generic; - public class ConfirmOrderStockCommandMsg : IntegrationEvent + public class ConfirmOrderStockCommand : IntegrationEvent { public int OrderId { get; } public IEnumerable OrderStockItems { get; } - public ConfirmOrderStockCommandMsg(int orderId, + public ConfirmOrderStockCommand(int orderId, IEnumerable orderStockItems) { OrderId = orderId; diff --git a/src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/DecrementOrderStockCommandMsg.cs b/src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/DecrementOrderStockCommand.cs similarity index 79% rename from src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/DecrementOrderStockCommandMsg.cs rename to src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/DecrementOrderStockCommand.cs index 94bab1aa6..ca241d6fd 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/DecrementOrderStockCommandMsg.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/DecrementOrderStockCommand.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class DecrementOrderStockCommandMsg : IntegrationEvent + public class DecrementOrderStockCommand : IntegrationEvent { public int OrderId { get; } public IEnumerable OrderStockItems { get; } - public DecrementOrderStockCommandMsg(int orderId, + public DecrementOrderStockCommand(int orderId, IEnumerable orderStockItems) { OrderId = orderId; diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs index be57329c7..b32b0dff5 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs @@ -20,12 +20,12 @@ public class ConfirmedOrderStockItem { public int ProductId { get; } - public bool Confirmed { get; } + public bool HasStock { get; } - public ConfirmedOrderStockItem(int productId, bool confirmed) + public ConfirmedOrderStockItem(int productId, bool hasStock) { ProductId = productId; - Confirmed = confirmed; + HasStock = hasStock; } } } \ No newline at end of file diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 1820e1f04..1f65e6a91 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -190,10 +190,10 @@ services.AddSingleton(); services.AddSingleton(); - services.AddTransient, - ConfirmOrderStockCommandMsgHandler>(); - services.AddTransient, - DecrementOrderStockCommandMsgHandler>(); + services.AddTransient, + ConfirmOrderStockCommandHandler>(); + services.AddTransient, + DecrementOrderStockCommandHandler>(); } @@ -201,8 +201,8 @@ { var eventBus = app.ApplicationServices.GetRequiredService(); - eventBus.Subscribe>(); - eventBus.Subscribe>(); + eventBus.Subscribe>(); + eventBus.Subscribe>(); } } } diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs index 06fd8bcfe..9a74d6a90 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs @@ -35,10 +35,10 @@ var orderStockList = orderStatusChangedToAwaitingValidationDomainEvent.OrderItems .Select(orderItem => new OrderStockItem(orderItem.ProductId, orderItem.GetUnits())); - var confirmOrderStockEvent = new ConfirmOrderStockCommandMsg(orderStatusChangedToAwaitingValidationDomainEvent.OrderId, + var confirmOrderStockCommand = new ConfirmOrderStockCommand(orderStatusChangedToAwaitingValidationDomainEvent.OrderId, orderStockList); - await _orderingIntegrationEventService.SaveEventAndOrderingContextChangesAsync(confirmOrderStockEvent); - await _orderingIntegrationEventService.PublishThroughEventBusAsync(confirmOrderStockEvent); + await _orderingIntegrationEventService.SaveEventAndOrderingContextChangesAsync(confirmOrderStockCommand); + await _orderingIntegrationEventService.PublishThroughEventBusAsync(confirmOrderStockCommand); } } } \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs index ade15b149..300d5d75f 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs @@ -35,10 +35,10 @@ var orderStockList = orderStatusChangedToPaidDomainEvent.OrderItems .Select(orderItem => new OrderStockItem(orderItem.ProductId, orderItem.GetUnits())); - var decrementOrderStockCommandMsg = new DecrementOrderStockCommandMsg(orderStatusChangedToPaidDomainEvent.OrderId, + var decrementOrderStockCommand = new DecrementOrderStockCommand(orderStatusChangedToPaidDomainEvent.OrderId, orderStockList); - await _orderingIntegrationEventService.SaveEventAndOrderingContextChangesAsync(decrementOrderStockCommandMsg); - await _orderingIntegrationEventService.PublishThroughEventBusAsync(decrementOrderStockCommandMsg); + await _orderingIntegrationEventService.SaveEventAndOrderingContextChangesAsync(decrementOrderStockCommand); + await _orderingIntegrationEventService.PublishThroughEventBusAsync(decrementOrderStockCommand); } } } \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs index 55b6d6c9a..272cbb061 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs @@ -31,9 +31,9 @@ .LogTrace($"Order with Id: {orderStatusChangedToStockConfirmedDomainEvent.OrderId} has been successfully updated with " + $"a status order id: {OrderStatus.StockConfirmed.Id}"); - var payOrderCommandMsg = new PayOrderCommandMsg(orderStatusChangedToStockConfirmedDomainEvent.OrderId); - await _orderingIntegrationEventService.SaveEventAndOrderingContextChangesAsync(payOrderCommandMsg); - await _orderingIntegrationEventService.PublishThroughEventBusAsync(payOrderCommandMsg); + var payOrderCommand = new PayOrderCommand(orderStatusChangedToStockConfirmedDomainEvent.OrderId); + await _orderingIntegrationEventService.SaveEventAndOrderingContextChangesAsync(payOrderCommand); + await _orderingIntegrationEventService.PublishThroughEventBusAsync(payOrderCommand); } } } \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmGracePeriodCommandMsg.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmGracePeriodCommand.cs similarity index 63% rename from src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmGracePeriodCommandMsg.cs rename to src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmGracePeriodCommand.cs index f9d8b8923..33b509f16 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmGracePeriodCommandMsg.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmGracePeriodCommand.cs @@ -2,11 +2,11 @@ namespace Ordering.API.Application.IntegrationCommands.Commands { - public class ConfirmGracePeriodCommandMsg : IntegrationEvent + public class ConfirmGracePeriodCommand : IntegrationEvent { public int OrderId { get; } - public ConfirmGracePeriodCommandMsg(int orderId) => + public ConfirmGracePeriodCommand(int orderId) => OrderId = orderId; } } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmOrderStockCommandMsg.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs similarity index 85% rename from src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmOrderStockCommandMsg.cs rename to src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs index 6e78598f1..b3f73617c 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmOrderStockCommandMsg.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class ConfirmOrderStockCommandMsg : IntegrationEvent + public class ConfirmOrderStockCommand : IntegrationEvent { public int OrderId { get; } public IEnumerable OrderStockItems { get; } - public ConfirmOrderStockCommandMsg(int orderId, + public ConfirmOrderStockCommand(int orderId, IEnumerable orderStockItems) { OrderId = orderId; diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/DecrementOrderStockCommandMsg.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/DecrementOrderStockCommand.cs similarity index 78% rename from src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/DecrementOrderStockCommandMsg.cs rename to src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/DecrementOrderStockCommand.cs index e05a20c48..3d0457ee8 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/DecrementOrderStockCommandMsg.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/DecrementOrderStockCommand.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class DecrementOrderStockCommandMsg : IntegrationEvent + public class DecrementOrderStockCommand : IntegrationEvent { public int OrderId { get; } public IEnumerable OrderStockItems { get; } - public DecrementOrderStockCommandMsg(int orderId, + public DecrementOrderStockCommand(int orderId, IEnumerable orderStockItems) { OrderId = orderId; diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/PayOrderCommandMsg.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/PayOrderCommand.cs similarity index 69% rename from src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/PayOrderCommandMsg.cs rename to src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/PayOrderCommand.cs index 749ec882e..8a3ca665c 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/PayOrderCommandMsg.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/PayOrderCommand.cs @@ -2,11 +2,11 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class PayOrderCommandMsg : IntegrationEvent + public class PayOrderCommand : IntegrationEvent { public int OrderId { get; } - public PayOrderCommandMsg(int orderId) + public PayOrderCommand(int orderId) { OrderId = orderId; } diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ShipOrderCommandMsg.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ShipOrderCommandMsg.cs deleted file mode 100644 index 5a8695ae9..000000000 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ShipOrderCommandMsg.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Ordering.API.Application.IntegrationCommands.Commands -{ - using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - - public class ShipOrderCommandMsg : IntegrationEvent - { - public int OrderId { get; } - - public ShipOrderCommandMsg(int orderId) - { - OrderId = orderId; - } - } -} \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockNotConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockNotConfirmedIntegrationEventHandler.cs index f3003c0a4..49708fe92 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockNotConfirmedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockNotConfirmedIntegrationEventHandler.cs @@ -22,7 +22,7 @@ namespace Ordering.API.Application.IntegrationEvents.EventHandling var orderToUpdate = await _orderRepository.GetWithDependenciesAsync(@event.OrderId); var orderStockNotConfirmedItems = @event.OrderStockItems - .FindAll(c => !c.Confirmed) + .FindAll(c => !c.HasStock) .Select(c => c.ProductId); orderToUpdate.SetStockConfirmedStatus(orderStockNotConfirmedItems); diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs index 5337c5eae..6bdb38ab2 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs @@ -21,12 +21,12 @@ namespace Ordering.API.Application.IntegrationEvents.Events public class ConfirmedOrderStockItem { public int ProductId { get; } - public bool Confirmed { get; } + public bool HasStock { get; } - public ConfirmedOrderStockItem(int productId, bool confirmed) + public ConfirmedOrderStockItem(int productId, bool hasStock) { ProductId = productId; - Confirmed = confirmed; + HasStock = hasStock; } } } \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Application/Sagas/OrderProcessSaga.cs b/src/Services/Ordering/Ordering.API/Application/Sagas/OrderProcessSaga.cs index 08b699a1f..a769c7e4c 100644 --- a/src/Services/Ordering/Ordering.API/Application/Sagas/OrderProcessSaga.cs +++ b/src/Services/Ordering/Ordering.API/Application/Sagas/OrderProcessSaga.cs @@ -21,7 +21,7 @@ namespace Ordering.API.Application.Sagas /// with the validations. /// public class OrderProcessSaga : OrderSaga, - IIntegrationEventHandler, + IIntegrationEventHandler, IAsyncRequestHandler, IAsyncRequestHandler { @@ -43,7 +43,7 @@ namespace Ordering.API.Application.Sagas /// period has completed. /// /// - public async Task Handle(ConfirmGracePeriodCommandMsg command) + public async Task Handle(ConfirmGracePeriodCommand command) { var orderSaga = FindSagaById(command.OrderId); CheckValidSagaId(orderSaga); diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 6f7828721..fc2bb90f2 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -171,7 +171,7 @@ services.AddSingleton(); services.AddTransient>(); - services.AddTransient, OrderProcessSaga>(); + services.AddTransient, OrderProcessSaga>(); services.AddTransient, OrderStockConfirmedIntegrationEventHandler>(); services.AddTransient, @@ -187,7 +187,7 @@ var eventBus = app.ApplicationServices.GetRequiredService(); eventBus.Subscribe>(); - eventBus.Subscribe>(); + eventBus.Subscribe>(); eventBus.Subscribe>(); eventBus.Subscribe>(); eventBus.Subscribe>(); diff --git a/src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/PayOrderCommandMsgHandler.cs b/src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/PayOrderCommandHandler.cs similarity index 71% rename from src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/PayOrderCommandMsgHandler.cs rename to src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/PayOrderCommandHandler.cs index 178b36474..ea1398cf8 100644 --- a/src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/PayOrderCommandMsgHandler.cs +++ b/src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/PayOrderCommandHandler.cs @@ -3,21 +3,17 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Payment.API.IntegrationCommands.Commands; using System.Threading.Tasks; - using System; using Payment.API.IntegrationEvents; using Payment.API.IntegrationEvents.Events; - public class PayOrderCommandMsgHandler : IIntegrationEventHandler + public class PayOrderCommandHandler : IIntegrationEventHandler { private readonly IPaymentIntegrationEventService _paymentIntegrationEventService; - public PayOrderCommandMsgHandler(IPaymentIntegrationEventService paymentIntegrationEventService) - { - _paymentIntegrationEventService = paymentIntegrationEventService; - } - + public PayOrderCommandHandler(IPaymentIntegrationEventService paymentIntegrationEventService) + => _paymentIntegrationEventService = paymentIntegrationEventService; - public async Task Handle(PayOrderCommandMsg @event) + public async Task Handle(PayOrderCommand @event) { //PAYMENT SUCCESSED var orderPaymentSuccededIntegrationEvent = new OrderPaymentSuccededIntegrationEvent(@event.OrderId); @@ -28,4 +24,4 @@ //_paymentIntegrationEventService.PublishThroughEventBus(orderPaymentFailedIntegrationEvent); } } -} +} \ No newline at end of file diff --git a/src/Services/Payment/Payment.API/IntegrationCommands/Commands/PayOrderCommandMsg.cs b/src/Services/Payment/Payment.API/IntegrationCommands/Commands/PayOrderCommand.cs similarity index 58% rename from src/Services/Payment/Payment.API/IntegrationCommands/Commands/PayOrderCommandMsg.cs rename to src/Services/Payment/Payment.API/IntegrationCommands/Commands/PayOrderCommand.cs index 360f40606..d6476fa6e 100644 --- a/src/Services/Payment/Payment.API/IntegrationCommands/Commands/PayOrderCommandMsg.cs +++ b/src/Services/Payment/Payment.API/IntegrationCommands/Commands/PayOrderCommand.cs @@ -2,10 +2,10 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class PayOrderCommandMsg : IntegrationEvent + public class PayOrderCommand : IntegrationEvent { public int OrderId { get; } - public PayOrderCommandMsg(int orderId) => OrderId = orderId; + public PayOrderCommand(int orderId) => OrderId = orderId; } } \ No newline at end of file diff --git a/src/Services/Payment/Payment.API/Startup.cs b/src/Services/Payment/Payment.API/Startup.cs index eaef3f704..e7a47f766 100644 --- a/src/Services/Payment/Payment.API/Startup.cs +++ b/src/Services/Payment/Payment.API/Startup.cs @@ -48,10 +48,8 @@ namespace Payment.API return new DefaultRabbitMQPersistentConnection(factory, logger); }); - services.AddSingleton(); - services.AddSingleton(); - services.AddTransient, PayOrderCommandMsgHandler>(); - + + RegisterServiceBus(services); services.AddSwaggerGen(); services.ConfigureSwaggerGen(options => @@ -85,10 +83,18 @@ namespace Payment.API ConfigureEventBus(app); } + private void RegisterServiceBus(IServiceCollection services) + { + services.AddSingleton(); + services.AddSingleton(); + + services.AddTransient, PayOrderCommandHandler>(); + } + private void ConfigureEventBus(IApplicationBuilder app) { var eventBus = app.ApplicationServices.GetRequiredService(); - eventBus.Subscribe>(); + eventBus.Subscribe>(); } } } diff --git a/src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommandMsg.cs b/src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommand.cs similarity index 54% rename from src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommandMsg.cs rename to src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommand.cs index 6521cd200..fd507a265 100644 --- a/src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommandMsg.cs +++ b/src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommand.cs @@ -2,10 +2,10 @@ { using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; - public class ConfirmGracePeriodCommandMsg : IntegrationEvent + public class ConfirmGracePeriodCommand : IntegrationEvent { public int OrderId { get;} - public ConfirmGracePeriodCommandMsg(int orderId) => OrderId = orderId; + public ConfirmGracePeriodCommand(int orderId) => OrderId = orderId; } } \ No newline at end of file diff --git a/src/Services/SagaManager/SagaManager/Program.cs b/src/Services/SagaManager/SagaManager/Program.cs index c285dfa76..97784fc85 100644 --- a/src/Services/SagaManager/SagaManager/Program.cs +++ b/src/Services/SagaManager/SagaManager/Program.cs @@ -37,7 +37,7 @@ while (true) { - sagaManagerService.CheckFinishedGracePeriodOrders(); + sagaManagerService.CheckConfirmedGracePeriodOrders(); await Task.Delay(90000); } } diff --git a/src/Services/SagaManager/SagaManager/Services/ISagaManagerService.cs b/src/Services/SagaManager/SagaManager/Services/ISagaManagerService.cs index dc027b29c..6ee012c37 100644 --- a/src/Services/SagaManager/SagaManager/Services/ISagaManagerService.cs +++ b/src/Services/SagaManager/SagaManager/Services/ISagaManagerService.cs @@ -2,6 +2,6 @@ { public interface ISagaManagerService { - void CheckFinishedGracePeriodOrders(); + void CheckConfirmedGracePeriodOrders(); } } \ No newline at end of file diff --git a/src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs b/src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs index 7ef5ae25a..f7455e27c 100644 --- a/src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs +++ b/src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs @@ -23,19 +23,18 @@ _logger = logger; } - public void CheckFinishedGracePeriodOrders() + public void CheckConfirmedGracePeriodOrders() { - var orderIds = GetFinishedGracePeriodOrders(); + var orderIds = GetConfirmedGracePeriodOrders(); foreach (var orderId in orderIds) { - var confirmGracePeriodEvent = new ConfirmGracePeriodCommandMsg(orderId); - + var confirmGracePeriodEvent = new ConfirmGracePeriodCommand(orderId); _sagaManagerIntegrationEventService.PublishThroughEventBus(confirmGracePeriodEvent); } } - private IEnumerable GetFinishedGracePeriodOrders() + private IEnumerable GetConfirmedGracePeriodOrders() { IEnumerable orderIds = new List(); using (var conn = new SqlConnection(_settings.ConnectionString))