Exemplo n.º 1
0
        public async Task Handle(OrderLabelPurchasedEvent message)
        {
            var notification = new NotificationAggregate
            {
                Id              = Guid.NewGuid().ToString(),
                Content         = "order_label_purchased",
                IsRead          = false,
                From            = message.SellerId,
                To              = message.Subject,
                CreatedDateTime = DateTime.UtcNow,
                Parameters      = new[]
                {
                    new NotificationParameter
                    {
                        Id    = Guid.NewGuid().ToString(),
                        Type  = NotificationParameterTypes.OrderId,
                        Value = message.OrderId
                    }
                }
            };

            await _notificationRepository.Add(notification);

            _eventPublisher.Publish(new NotificationAddedEvent
            {
                Id      = notification.Id,
                Content = notification.Content,
                IsRead  = notification.IsRead,
                From    = notification.From,
                To      = notification.To
            });
        }
Exemplo n.º 2
0
        public Task Handle(OrderLabelPurchasedEvent message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var notifier = _connectionManager.GetHubContext <SecuredHub>();
            var lst      = new[] { message.Subject, message.SellerId };

            lst.Distinct();
            var connectionIds = new List <string>();

            foreach (var r in lst)
            {
                connectionIds.AddRange(SecuredHub.Connections.GetConnections(r).ToList());
            }

            notifier.Clients.Clients(connectionIds).orderLabelPurchased(_responseBuilder.GetOrderLabelPurchased(message));
            return(Task.FromResult(0));
        }