31 lines
1.3 KiB
C#
31 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
|
|
|
|
public class OrderStatusChangedToCompletedIntegrationEventHandler : IIntegrationEventHandler<OrderStatusChangedToCompletedIntegrationEvent>
|
|
{
|
|
private readonly IHubContext<NotificationsHub> _hubContext;
|
|
private readonly ILogger<OrderStatusChangedToCompletedIntegrationEventHandler> _logger;
|
|
|
|
public OrderStatusChangedToCompletedIntegrationEventHandler(
|
|
IHubContext<NotificationsHub> hubContext,
|
|
ILogger<OrderStatusChangedToCompletedIntegrationEventHandler> logger)
|
|
{
|
|
_hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext));
|
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
}
|
|
|
|
|
|
public async Task Handle(OrderStatusChangedToCompletedIntegrationEvent @event)
|
|
{
|
|
using (_logger.BeginScope(new List<KeyValuePair<string, object>> { new ("IntegrationEventContext", @event.Id) }))
|
|
{
|
|
_logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
|
|
|
|
await _hubContext.Clients
|
|
.Group(@event.BuyerName)
|
|
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });
|
|
}
|
|
}
|
|
}
|