public async Task Handle(RaffleItemUpdated notification, CancellationToken cancellationToken) { var raffleItem = RaffleItemDuringRunMapper.Map(notification.RaffleItem); var ordersResult = await mediator.Send(new GetRaffleOrdersQuery()); var possibleWinners = ordersResult.Orders.Select(x => new { Name = $"{x.Customer.FirstName} {x.Customer.LastName}", Tickets = GetOrderTickets(x.TicketNumber) }); foreach (var winningTicket in raffleItem.WinningTickets) { var winner = possibleWinners.Where(x => x.Tickets.Contains(winningTicket.Number)).FirstOrDefault(); raffleItem.Winners.Add(new Winner { Name = winner.Name, For = winningTicket.For, TicketNumber = winningTicket.Number }); } await hub.Clients.All.RaffleItemUpdated(raffleItem); }
public Task RaffleItemUpdated(RaffleItem raffleItem) { return(Clients.All.RaffleItemUpdated(RaffleItemDuringRunMapper.Map(raffleItem))); }