public async Task Handle(UpdateStockCommand notification, CancellationToken cancellationToken)
        {
            await _orderEventService.SaveEvent(notification.Order, OrderEventType.OrderCreated);

            _eventBus.Publish(new UpdateStockOnCreateOrderEvent(notification.Order.Id,
                                                                notification.Order.OrderDetails.ToList()));
        }
        public async Task Handle(UpdateOrderCommand notification, CancellationToken cancellationToken)
        {
            var lastEvent = await _queryOrderEvent.GetLastEvent(notification.Order.Id);

            _eventBus.Publish(new ProductUpdateOnUpdateOrderEvent(notification.Order.Id,
                                                                  notification.Order.OrderDetails.ToList(), lastEvent.OrderDetails));
            await _orderEventService.SaveEvent(notification.Order, OrderEventType.OrderUpdated);
        }
Пример #3
0
        public async Task Handle(DeleteOrderItemCommand notification, CancellationToken cancellationToken)
        {
            _repository.PartialUpdate(new Orders
            {
                Id           = notification.Order.Id,
                Total        = notification.Order.Total,
                OverallTotal = notification.Order.OverallTotal
            }, new List <string> {
                "Total", "OverallTotal"
            });
            _orderDetailRepository.Remove(notification.Order.OrderDetails.ToList()[0].Id, "");
            await _repository.SaveAsync();

            await _orderEventService.SaveEvent(notification.Order, OrderEventType.DeleteOrderItem);

            _eventBus.Publish(new DeleteOrderItemEvent(notification.Order.Id,
                                                       notification.Order.OrderDetails.ToList()[0]));
        }