2021-10-20 17:23:38 +05:30
|
|
|
namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
|
|
|
|
|
2021-10-11 17:57:30 +05:30
|
|
|
public class OrderStatusChangedToSubmittedIntegrationEventHandler :
|
|
|
|
IIntegrationEventHandler<OrderStatusChangedToSubmittedIntegrationEvent>
|
2018-04-19 00:58:09 +02:00
|
|
|
{
|
2021-10-11 17:57:30 +05:30
|
|
|
private readonly IHubContext<NotificationsHub> _hubContext;
|
|
|
|
private readonly ILogger<OrderStatusChangedToSubmittedIntegrationEventHandler> _logger;
|
2018-04-19 00:58:09 +02:00
|
|
|
|
2021-10-11 17:57:30 +05:30
|
|
|
public OrderStatusChangedToSubmittedIntegrationEventHandler(
|
|
|
|
IHubContext<NotificationsHub> hubContext,
|
|
|
|
ILogger<OrderStatusChangedToSubmittedIntegrationEventHandler> logger)
|
|
|
|
{
|
|
|
|
_hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext));
|
|
|
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
|
|
}
|
2018-04-19 00:58:09 +02:00
|
|
|
|
|
|
|
|
2021-10-11 17:57:30 +05:30
|
|
|
public async Task Handle(OrderStatusChangedToSubmittedIntegrationEvent @event)
|
|
|
|
{
|
|
|
|
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}"))
|
2018-04-19 00:58:09 +02:00
|
|
|
{
|
2021-10-11 17:57:30 +05:30
|
|
|
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
|
2019-02-18 19:33:04 +00:00
|
|
|
|
2021-10-11 17:57:30 +05:30
|
|
|
await _hubContext.Clients
|
|
|
|
.Group(@event.BuyerName)
|
|
|
|
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });
|
2018-04-19 00:58:09 +02:00
|
|
|
}
|
|
|
|
}
|
2021-10-11 17:57:30 +05:30
|
|
|
}
|