From 0cc909b660f0927e1b03bb2e67c0702d8cc72140 Mon Sep 17 00:00:00 2001 From: hsn Date: Tue, 11 Jul 2023 09:22:41 +0300 Subject: [PATCH] Wrongly located Integration event is removed. --- .../OrderCompletedIntegrationEventHandler.cs | 40 ------------------- .../Events/OrderCompletedIntegrationEvent.cs | 10 ----- src/Services/Ordering/Ordering.API/Program.cs | 2 - 3 files changed, 52 deletions(-) delete mode 100644 src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderCompletedIntegrationEventHandler.cs delete mode 100644 src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderCompletedIntegrationEvent.cs diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderCompletedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderCompletedIntegrationEventHandler.cs deleted file mode 100644 index dcc3f0c43..000000000 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderCompletedIntegrationEventHandler.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.EventHandling; - -public class OrderCompletedIntegrationEventHandler : IIntegrationEventHandler -{ - private readonly IMediator _mediator; - private readonly ILogger _logger; - - public OrderCompletedIntegrationEventHandler( - IMediator mediator, - ILogger logger) - { - _mediator = mediator; - _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); - } - - /// - /// Event handler which confirms order is completed. - /// - /// - /// - /// - public async Task Handle(OrderCompletedIntegrationEvent @event) - { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) - { - _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); - - var command = new SetAwaitingValidationOrderStatusCommand(@event.OrderId); - - _logger.LogInformation( - "Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", - command.GetGenericTypeName(), - nameof(command.OrderNumber), - command.OrderNumber, - command); - - await _mediator.Send(command); - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderCompletedIntegrationEvent.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderCompletedIntegrationEvent.cs deleted file mode 100644 index 555cb1ee4..000000000 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderCompletedIntegrationEvent.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.Events; - -public record OrderCompletedIntegrationEvent : IntegrationEvent -{ - public int OrderId { get; } - - public OrderCompletedIntegrationEvent(int orderId) => - OrderId = orderId; -} - diff --git a/src/Services/Ordering/Ordering.API/Program.cs b/src/Services/Ordering/Ordering.API/Program.cs index e3bd21f2a..cab0e0b95 100644 --- a/src/Services/Ordering/Ordering.API/Program.cs +++ b/src/Services/Ordering/Ordering.API/Program.cs @@ -35,7 +35,6 @@ services.AddScoped(); // Add integration event handlers. services.AddTransient, GracePeriodConfirmedIntegrationEventHandler>(); -services.AddTransient, OrderCompletedIntegrationEventHandler>(); services.AddTransient, OrderPaymentFailedIntegrationEventHandler>(); services.AddTransient, OrderPaymentSucceededIntegrationEventHandler>(); services.AddTransient, OrderStockConfirmedIntegrationEventHandler>(); @@ -53,7 +52,6 @@ var eventBus = app.Services.GetRequiredService(); eventBus.Subscribe>(); eventBus.Subscribe>(); -eventBus.Subscribe>(); eventBus.Subscribe>(); eventBus.Subscribe>(); eventBus.Subscribe>();