public async Task <IActionResult> GetBuyer(int id) { Buyer buyer = await buyerRepository.FindByIdAsync(id); if (buyer == null) { return(NotFound()); } return(new ObjectResult(buyer)); }
public async Task Handle(OrderStatusChangedToStockConfirmedDomainEvent orderStatusChangedToStockConfirmedDomainEvent, CancellationToken cancellationToken) { var order = await _orderRepository.GetAsync(orderStatusChangedToStockConfirmedDomainEvent.OrderId); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); // TODO: Publish new Order Status Changed To Stock Confirmed Integration Event }
public async Task Handle(OrderShippedDomainEvent orderShippedDomainEvent, CancellationToken cancellationToken) { var order = await _orderRepository.GetAsync(orderShippedDomainEvent.Order.Id); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var orderStatusChangedToShippedIntegrationEvent = new OrderStatusChangedToShippedIntegrationEvent(order.Id, order.OrderStatus.Name, buyer.Name); await _messageOutbox.Send(orderStatusChangedToShippedIntegrationEvent); }
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent, CancellationToken cancellationToken) { var order = await _orderRepository.GetAsync(orderStatusChangedToAwaitingValidationDomainEvent.OrderId); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); // TODO: Create list of OrderStockItems based on orderStatusChangedToAwaitingValidationDomainEvent.OrderItems using OrderItem.ProductId and OrderItem.GetUnits() // TODO: Publish new Order Status Changed To Awaiting Validation Integration Event }
public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent, CancellationToken cancellationToken) { var order = await _orderRepository.GetAsync(orderStatusChangedToPaidDomainEvent.OrderId); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var orderStockList = orderStatusChangedToPaidDomainEvent.OrderItems .Select(orderItem => new OrderStockItem(orderItem.ProductId, orderItem.GetUnits())); // TODO: Publish new Order Status Changed To Paid Integration Event }
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent, CancellationToken cancellationToken) { var order = await _orderRepository.GetAsync(orderStatusChangedToAwaitingValidationDomainEvent.OrderId); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var orderStockList = orderStatusChangedToAwaitingValidationDomainEvent.OrderItems .Select(orderItem => new OrderStockItem(orderItem.ProductId, orderItem.GetUnits())); var orderStatusChangedToAwaitingValidationIntegrationEvent = new OrderStatusChangedToAwaitingValidationIntegrationEvent( order.Id, order.OrderStatus.Name, buyer.Name, orderStockList); await _messageOutbox.Send(orderStatusChangedToAwaitingValidationIntegrationEvent); }
public async Task Handle(OrderShippedDomainEvent orderShippedDomainEvent, CancellationToken cancellationToken) { _logger.CreateLogger(nameof(OrderShippedDomainEvent)) .LogTrace($"Order with Id: {orderShippedDomainEvent.Order.Id} has been successfully updated with " + $"a status order id: {OrderStatus.Shipped.Id}"); var order = await _orderRepository.GetAsync(orderShippedDomainEvent.Order.Id); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var orderStatusChangedToShippedIntegrationEvent = new OrderStatusChangedToShippedIntegrationEvent(order.Id, order.OrderStatus.Name, buyer.Name); await _orderingIntegrationEventService.PublishThroughEventBusAsync(orderStatusChangedToShippedIntegrationEvent); }
public async Task Handle(OrderStatusChangedToStockConfirmedDomainEvent orderStatusChangedToStockConfirmedDomainEvent, CancellationToken cancellationToken) { _logger.CreateLogger <OrderStatusChangedToStockConfirmedDomainEventHandler>() .LogTrace("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})", orderStatusChangedToStockConfirmedDomainEvent.OrderId, nameof(OrderStatus.StockConfirmed), OrderStatus.StockConfirmed.Id); var order = await _orderRepository.GetAsync(orderStatusChangedToStockConfirmedDomainEvent.OrderId); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var orderStatusChangedToStockConfirmedIntegrationEvent = new OrderStatusChangedToStockConfirmedIntegrationEvent(order.Id, order.OrderStatus.Name, buyer.Name); await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedToStockConfirmedIntegrationEvent); }
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent, CancellationToken cancellationToken) { _logger.CreateLogger(nameof(OrderStatusChangedToAwaitingValidationDomainEvent)) .LogTrace($"Order with Id: {orderStatusChangedToAwaitingValidationDomainEvent.OrderId} has been successfully updated with " + $"a status order id: {OrderStatus.AwaitingValidation.Id}"); var order = await _orderRepository.GetAsync(orderStatusChangedToAwaitingValidationDomainEvent.OrderId); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var orderStockList = orderStatusChangedToAwaitingValidationDomainEvent.OrderItems .Select(orderItem => new OrderStockItem(orderItem.ProductId, orderItem.GetUnits())); var orderStatusChangedToAwaitingValidationIntegrationEvent = new OrderStatusChangedToAwaitingValidationIntegrationEvent( order.Id, order.OrderStatus.Name, buyer.Name, orderStockList); await _orderingIntegrationEventService.PublishThroughEventBusAsync(orderStatusChangedToAwaitingValidationIntegrationEvent); }
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent, CancellationToken cancellationToken) { _logger.CreateLogger <OrderStatusChangedToAwaitingValidationDomainEvent>() .LogTrace("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})", orderStatusChangedToAwaitingValidationDomainEvent.OrderId, nameof(OrderStatus.AwaitingValidation), OrderStatus.AwaitingValidation.Id); var order = await _orderRepository.GetAsync(orderStatusChangedToAwaitingValidationDomainEvent.OrderId); var buyer = await _buyerRepository.FindByIdAsync(order.GetBuyerId.Value.ToString()); var orderStockList = orderStatusChangedToAwaitingValidationDomainEvent.OrderItems .Select(orderItem => new OrderStockItem(orderItem.ProductId, orderItem.GetUnits())); var orderStatusChangedToAwaitingValidationIntegrationEvent = new OrderStatusChangedToAwaitingValidationIntegrationEvent( order.Id, order.OrderStatus.Name, buyer.Name, orderStockList); await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedToAwaitingValidationIntegrationEvent); }
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); }