public async Task <bool> Handle(OrderSetToBilledCommand command, CancellationToken cancellationToken) { _logger.LogInformation($"Handle({nameof(OrderSetToBilledCommandHandler)}) -> {command}"); var orderToUpdate = await _orderQuery.FindByIdAsync(command.OrderId); orderToUpdate.SetPaidStatus(); return(await _orderRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken)); }
// Domain Logic comment: // When the Buyer and Buyer's payment method have been created or verified that they existed, // then we can update the original Order with the BuyerId and PaymentId (foreign keys) public async Task Handle(CustomerAndPaymentMethodVerifiedDomainEvent @event, CancellationToken cancellationToken) { // var command = new OrderByIdQuery(@event.OrderId); // var model = await _mediator.Send(command); // var orderToUpdate = model.ToOrder(); var orderToUpdate = await _orderQuery.FindByIdAsync(@event.OrderId); orderToUpdate.SetCustomerId(@event.Customer.Id); orderToUpdate.SetPaymentId(@event.Payment.Id); await _orderRepository.UnitOfWork.SaveEntitiesAsync(); _logger.LogTrace($"Order with Id: {@event.OrderId} has been successfully updated with a payment method {nameof(@event.Payment)} ({@event.Payment.Id})"); }
public async Task <OrderModel> Handle(OrderByIdQuery request, CancellationToken cancellationToken) { var entityOrder = await _orderQuery.FindByIdAsync(request.OrderId); return(entityOrder.ToOrderModel()); }