Example #1
0
        public async Task Handle(OrderCanceledEvent message)
        {
            var notification = new NotificationAggregate
            {
                Id              = Guid.NewGuid().ToString(),
                Content         = "order_label_canceled",
                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
            });
        }
        private ConsumeContext <OrderCanceledEvent> GetContext()
        {
            var orderCanceledEvent = new OrderCanceledEvent {
                OrderItems = orderItems
            };

            return(Mock.Of <ConsumeContext <OrderCanceledEvent> >(x => x.Message == orderCanceledEvent));
        }
Example #3
0
        public void WhenCancelIsInvoked_ThenGenerateOrderCancelEvent()
        {
            //arrange
            string             id     = Guid.NewGuid().ToString();
            Order              target = new Order(id, "John", new List <OrderDetail>(), DateTimeOffset.Now);
            OrderCanceledEvent expect = new OrderCanceledEvent(1, id);

            //act
            target.Cancel();
            OrderCanceledEvent actual = target.IterateEvent().First() as OrderCanceledEvent;

            //assert
            target.Status.Should().Be(OrderStatus.Cancel);
            actual.Should().Equals(expect);
        }
        private async Task SendOrderCanceledEventAsync(Guid processingUserId, Guid anotherUserId, Guid dealId, Guid orderId, string description)
        {
            var @event = new OrderCanceledEvent
            {
                ProcessingUserId = processingUserId,
                AnotherUserId    = anotherUserId,
                DealId           = dealId,
                OrderId          = orderId,
                Description      = description
            };

            _messageSession = (IMessageSession)_serviceProvider.GetService(typeof(IMessageSession));
            await _messageSession.Publish(@event);

            _logger.LogInformation("----- Published OrderCanceledEvent: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event);
        }
Example #5
0
        public Task Handle(OrderCanceledEvent message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

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

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

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

            notifier.Clients.Clients(connectionIds).orderCanceled(_responseBuilder.GetOrderCanceled(message));
            return(Task.FromResult(0));
        }
Example #6
0
        private void OrderCanceledReceived(Message message)
        {
            OrderCanceledData data = new OrderCanceledData(message);

            OrderCanceledEvent?.Invoke(data);
        }
Example #7
0
 public void Handle(OrderCanceledEvent notification)
 {
 }
 public bool EmitOrderCanceledEvent(OrderCanceledEvent evt)
 {
     return(true);
 }
Example #9
0
 public async Task Handle(OrderCanceledEvent message, CancellationToken cancellationToken)
 {
     await _courseService.DisenrollCourse(message.CoursesOrder);
 }
        private ConsumeContext <OrderCanceledEvent> GetContext(int id = id)
        {
            var orderCanceledEvent = new OrderCanceledEvent(id);

            return(Mock.Of <ConsumeContext <OrderCanceledEvent> >(x => x.Message == orderCanceledEvent));
        }