27 lines
1002 B
C#
27 lines
1002 B
C#
|
using Microsoft.AspNetCore.SignalR;
|
|||
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
|||
|
using Ordering.SignalrHub.IntegrationEvents.Events;
|
|||
|
using System;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Ordering.SignalrHub.IntegrationEvents.EventHandling
|
|||
|
{
|
|||
|
public class OrderStatusChangedToPaidIntegrationEventHandler : IIntegrationEventHandler<OrderStatusChangedToPaidIntegrationEvent>
|
|||
|
{
|
|||
|
private readonly IHubContext<NotificationsHub> _hubContext;
|
|||
|
|
|||
|
public OrderStatusChangedToPaidIntegrationEventHandler(IHubContext<NotificationsHub> hubContext)
|
|||
|
{
|
|||
|
_hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext));
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public async Task Handle(OrderStatusChangedToPaidIntegrationEvent @event)
|
|||
|
{
|
|||
|
await _hubContext.Clients
|
|||
|
.Group(@event.BuyerName)
|
|||
|
.SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus });
|
|||
|
}
|
|||
|
}
|
|||
|
}
|