Browse Source

naming changes

pull/223/head
Christian Arenas 7 years ago
parent
commit
9b449461f2
25 changed files with 75 additions and 88 deletions
  1. +7
    -7
      src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/ConfirmOrderStockCommandHandler.cs
  2. +4
    -4
      src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandHandler.cs
  3. +2
    -2
      src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs
  4. +2
    -2
      src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/DecrementOrderStockCommand.cs
  5. +3
    -3
      src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs
  6. +6
    -6
      src/Services/Catalog/Catalog.API/Startup.cs
  7. +3
    -3
      src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs
  8. +3
    -3
      src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs
  9. +3
    -3
      src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs
  10. +2
    -2
      src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmGracePeriodCommand.cs
  11. +2
    -2
      src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs
  12. +2
    -2
      src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/DecrementOrderStockCommand.cs
  13. +2
    -2
      src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/PayOrderCommand.cs
  14. +0
    -14
      src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ShipOrderCommandMsg.cs
  15. +1
    -1
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockNotConfirmedIntegrationEventHandler.cs
  16. +3
    -3
      src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs
  17. +2
    -2
      src/Services/Ordering/Ordering.API/Application/Sagas/OrderProcessSaga.cs
  18. +2
    -2
      src/Services/Ordering/Ordering.API/Startup.cs
  19. +5
    -9
      src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/PayOrderCommandHandler.cs
  20. +2
    -2
      src/Services/Payment/Payment.API/IntegrationCommands/Commands/PayOrderCommand.cs
  21. +11
    -5
      src/Services/Payment/Payment.API/Startup.cs
  22. +2
    -2
      src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommand.cs
  23. +1
    -1
      src/Services/SagaManager/SagaManager/Program.cs
  24. +1
    -1
      src/Services/SagaManager/SagaManager/Services/ISagaManagerService.cs
  25. +4
    -5
      src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs

src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/ConfirmOrderStockCommandMsgHandler.cs → src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/ConfirmOrderStockCommandHandler.cs View File

@ -12,23 +12,23 @@
using Commands;
using IntegrationEvents.Events;
public class ConfirmOrderStockCommandMsgHandler : IIntegrationEventHandler<ConfirmOrderStockCommandMsg>
public class ConfirmOrderStockCommandHandler : IIntegrationEventHandler<ConfirmOrderStockCommand>
{
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<ConfirmedOrderStockItem>();
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);

src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandMsgHandler.cs → src/Services/Catalog/Catalog.API/IntegrationCommands/CommandHandlers/DecrementOrderStockCommandHandler.cs View File

@ -5,19 +5,19 @@
using Infrastructure;
using Commands;
public class DecrementOrderStockCommandMsgHandler : IIntegrationEventHandler<DecrementOrderStockCommandMsg>
public class DecrementOrderStockCommandHandler : IIntegrationEventHandler<DecrementOrderStockCommand>
{
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);

src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/ConfirmOrderStockCommandMsg.cs → src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs View File

@ -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<OrderStockItem> OrderStockItems { get; }
public ConfirmOrderStockCommandMsg(int orderId,
public ConfirmOrderStockCommand(int orderId,
IEnumerable<OrderStockItem> orderStockItems)
{
OrderId = orderId;

src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/DecrementOrderStockCommandMsg.cs → src/Services/Catalog/Catalog.API/IntegrationCommands/Commands/DecrementOrderStockCommand.cs View File

@ -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<OrderStockItem> OrderStockItems { get; }
public DecrementOrderStockCommandMsg(int orderId,
public DecrementOrderStockCommand(int orderId,
IEnumerable<OrderStockItem> orderStockItems)
{
OrderId = orderId;

+ 3
- 3
src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs View File

@ -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;
}
}
}

+ 6
- 6
src/Services/Catalog/Catalog.API/Startup.cs View File

@ -190,10 +190,10 @@
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
services.AddSingleton<IEventBus, EventBusRabbitMQ>();
services.AddTransient<IIntegrationEventHandler<ConfirmOrderStockCommandMsg>,
ConfirmOrderStockCommandMsgHandler>();
services.AddTransient<IIntegrationEventHandler<DecrementOrderStockCommandMsg>,
DecrementOrderStockCommandMsgHandler>();
services.AddTransient<IIntegrationEventHandler<ConfirmOrderStockCommand>,
ConfirmOrderStockCommandHandler>();
services.AddTransient<IIntegrationEventHandler<DecrementOrderStockCommand>,
DecrementOrderStockCommandHandler>();
}
@ -201,8 +201,8 @@
{
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
eventBus.Subscribe<ConfirmOrderStockCommandMsg, IIntegrationEventHandler<ConfirmOrderStockCommandMsg>>();
eventBus.Subscribe<DecrementOrderStockCommandMsg, IIntegrationEventHandler<DecrementOrderStockCommandMsg>>();
eventBus.Subscribe<ConfirmOrderStockCommand, IIntegrationEventHandler<ConfirmOrderStockCommand>>();
eventBus.Subscribe<DecrementOrderStockCommand, IIntegrationEventHandler<DecrementOrderStockCommand>>();
}
}
}

+ 3
- 3
src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs View File

@ -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);
}
}
}

+ 3
- 3
src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs View File

@ -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);
}
}
}

+ 3
- 3
src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs View File

@ -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);
}
}
}

src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmGracePeriodCommandMsg.cs → src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmGracePeriodCommand.cs View File

@ -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;
}
}

src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmOrderStockCommandMsg.cs → src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ConfirmOrderStockCommand.cs View File

@ -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<OrderStockItem> OrderStockItems { get; }
public ConfirmOrderStockCommandMsg(int orderId,
public ConfirmOrderStockCommand(int orderId,
IEnumerable<OrderStockItem> orderStockItems)
{
OrderId = orderId;

src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/DecrementOrderStockCommandMsg.cs → src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/DecrementOrderStockCommand.cs View File

@ -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<OrderStockItem> OrderStockItems { get; }
public DecrementOrderStockCommandMsg(int orderId,
public DecrementOrderStockCommand(int orderId,
IEnumerable<OrderStockItem> orderStockItems)
{
OrderId = orderId;

src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/PayOrderCommandMsg.cs → src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/PayOrderCommand.cs View File

@ -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;
}

+ 0
- 14
src/Services/Ordering/Ordering.API/Application/IntegrationCommands/Commands/ShipOrderCommandMsg.cs View File

@ -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;
}
}
}

+ 1
- 1
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockNotConfirmedIntegrationEventHandler.cs View File

@ -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);


+ 3
- 3
src/Services/Ordering/Ordering.API/Application/IntegrationEvents/Events/OrderStockNotConfirmedIntegrationEvent.cs View File

@ -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;
}
}
}

+ 2
- 2
src/Services/Ordering/Ordering.API/Application/Sagas/OrderProcessSaga.cs View File

@ -21,7 +21,7 @@ namespace Ordering.API.Application.Sagas
/// with the validations.
/// </summary>
public class OrderProcessSaga : OrderSaga,
IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>,
IIntegrationEventHandler<ConfirmGracePeriodCommand>,
IAsyncRequestHandler<CancelOrderCommand, bool>,
IAsyncRequestHandler<ShipOrderCommand, bool>
{
@ -43,7 +43,7 @@ namespace Ordering.API.Application.Sagas
/// period has completed.
/// </param>
/// <returns></returns>
public async Task Handle(ConfirmGracePeriodCommandMsg command)
public async Task Handle(ConfirmGracePeriodCommand command)
{
var orderSaga = FindSagaById(command.OrderId);
CheckValidSagaId(orderSaga);


+ 2
- 2
src/Services/Ordering/Ordering.API/Startup.cs View File

@ -171,7 +171,7 @@
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
services.AddTransient<IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>>();
services.AddTransient<IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>, OrderProcessSaga>();
services.AddTransient<IIntegrationEventHandler<ConfirmGracePeriodCommand>, OrderProcessSaga>();
services.AddTransient<IIntegrationEventHandler<OrderStockConfirmedIntegrationEvent>,
OrderStockConfirmedIntegrationEventHandler>();
services.AddTransient<IIntegrationEventHandler<OrderStockNotConfirmedIntegrationEvent>,
@ -187,7 +187,7 @@
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
eventBus.Subscribe<UserCheckoutAcceptedIntegrationEvent, IIntegrationEventHandler<UserCheckoutAcceptedIntegrationEvent>>();
eventBus.Subscribe<ConfirmGracePeriodCommandMsg, IIntegrationEventHandler<ConfirmGracePeriodCommandMsg>>();
eventBus.Subscribe<ConfirmGracePeriodCommand, IIntegrationEventHandler<ConfirmGracePeriodCommand>>();
eventBus.Subscribe<OrderStockConfirmedIntegrationEvent, IIntegrationEventHandler<OrderStockConfirmedIntegrationEvent>>();
eventBus.Subscribe<OrderStockNotConfirmedIntegrationEvent, IIntegrationEventHandler<OrderStockNotConfirmedIntegrationEvent>>();
eventBus.Subscribe<OrderPaymentFailedIntegrationEvent, IIntegrationEventHandler<OrderPaymentFailedIntegrationEvent>>();


src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/PayOrderCommandMsgHandler.cs → src/Services/Payment/Payment.API/IntegrationCommands/CommandHandlers/PayOrderCommandHandler.cs View File

@ -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<PayOrderCommandMsg>
public class PayOrderCommandHandler : IIntegrationEventHandler<PayOrderCommand>
{
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);
}
}
}
}

src/Services/Payment/Payment.API/IntegrationCommands/Commands/PayOrderCommandMsg.cs → src/Services/Payment/Payment.API/IntegrationCommands/Commands/PayOrderCommand.cs View File

@ -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;
}
}

+ 11
- 5
src/Services/Payment/Payment.API/Startup.cs View File

@ -48,10 +48,8 @@ namespace Payment.API
return new DefaultRabbitMQPersistentConnection(factory, logger);
});
services.AddSingleton<IEventBus, EventBusRabbitMQ>();
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
services.AddTransient<IIntegrationEventHandler<PayOrderCommandMsg>, PayOrderCommandMsgHandler>();
RegisterServiceBus(services);
services.AddSwaggerGen();
services.ConfigureSwaggerGen(options =>
@ -85,10 +83,18 @@ namespace Payment.API
ConfigureEventBus(app);
}
private void RegisterServiceBus(IServiceCollection services)
{
services.AddSingleton<IEventBus, EventBusRabbitMQ>();
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
services.AddTransient<IIntegrationEventHandler<PayOrderCommand>, PayOrderCommandHandler>();
}
private void ConfigureEventBus(IApplicationBuilder app)
{
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
eventBus.Subscribe<PayOrderCommandMsg, IIntegrationEventHandler<PayOrderCommandMsg>>();
eventBus.Subscribe<PayOrderCommand, IIntegrationEventHandler<PayOrderCommand>>();
}
}
}

src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommandMsg.cs → src/Services/SagaManager/SagaManager/IntegrationEvents/Events/ConfirmGracePeriodCommand.cs View File

@ -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;
}
}

+ 1
- 1
src/Services/SagaManager/SagaManager/Program.cs View File

@ -37,7 +37,7 @@
while (true)
{
sagaManagerService.CheckFinishedGracePeriodOrders();
sagaManagerService.CheckConfirmedGracePeriodOrders();
await Task.Delay(90000);
}
}


+ 1
- 1
src/Services/SagaManager/SagaManager/Services/ISagaManagerService.cs View File

@ -2,6 +2,6 @@
{
public interface ISagaManagerService
{
void CheckFinishedGracePeriodOrders();
void CheckConfirmedGracePeriodOrders();
}
}

+ 4
- 5
src/Services/SagaManager/SagaManager/Services/SagaManagerService.cs View File

@ -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<int> GetFinishedGracePeriodOrders()
private IEnumerable<int> GetConfirmedGracePeriodOrders()
{
IEnumerable<int> orderIds = new List<int>();
using (var conn = new SqlConnection(_settings.ConnectionString))


Loading…
Cancel
Save