public async Task Handle(OrderCancelledDomainEvent notification, CancellationToken cancellationToken) { _logger.LogInformation(" [x] OrderCancelledDomainEventHandler: Handling domain event..."); var integrationEvent = new OrderCancelledIntegrationEvent(orderId: notification.OrderId, reason: notification.CancellationReason); _logger.LogInformation(" [x] OrderCancelledDomainEventHandler: Publishing integration event OrderCancelledIntegrationEvent"); await _orderingIntegrationEventService.PublishEvent(integrationEvent); }
public async Task Handle(OrderStatusChangedToAwaitingStockValidationDomainEvent notification, CancellationToken cancellationToken) { //Publish integration event here. //Prepare orderStockItems, //Publish integration event. var orderItems = notification.OrderItems; List <OrderStockItem> orderStockItems = new List <OrderStockItem>(); foreach (var item in orderItems) { orderStockItems.Add(new OrderStockItem(item.ProductId, item.GetUnits())); } _logger.LogInformation(" [x] OrderStatusChangedToAwaitingStockValidationDomainEventHandler: Handling domain event and creating an OrderStatusChangedToAwaitingStockValidationIntegrationEvent to publish to RabbitMQ..."); var integrationEvent = new OrderStatusChangedToAwaitingStockValidationIntegrationEvent(orderId: notification.OrderId, orderStockItems: orderStockItems); await _orderingIntegrationEventService.AddIntegrationEventToLog(@integrationEvent, null); await _orderingIntegrationEventService.PublishEvent(integrationEvent); }
public async Task Handle(OrderStatusChangedToStockConfirmedDomainEvent notification, CancellationToken cancellationToken) { _logger.LogInformation(" [x] SendStockConfirmedIntegrationEventWhenStockConfirmed: " + "Preparing integration event: OrderStatusChangedToStockConfirmedIntegrationEvent"); var order = await _orderRepository.GetAsync(notification.OrderId); var buyer = await _buyerRepository.FindByIdAsync(Convert.ToInt32(order.GetBuyerId)); var paymentMethod = buyer.PaymentMethods.First(); var integrationEvent = new OrderStatusChangedToStockConfirmedIntegrationEvent(notification.OrderId, buyer: buyer.Name, paymentMethod: PaymentMethodDTO.ToPaymentMethodDto(paymentMethod)); _logger.LogInformation(" [x] SendStockConfirmedIntegrationEventWhenStockConfirmed: " + "Integration event is publishing through event bus. Order ID: {0}, Buyer: {1}, PaymentMethod: {2}", order.Id, buyer.Name, paymentMethod.CardNumber); await _orderingIntegrationEventService.AddIntegrationEventToLog(integrationEvent, null); await _orderingIntegrationEventService.PublishEvent(integrationEvent); }