public async Task Handle(OrderPaymentFailedIntegrationEvent @event) { using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); var command = new CancelOrderCommand(@event.OrderId); _logger.LogInformation( "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", command.GetGenericTypeName(), nameof(command.OrderNumber), command.OrderNumber, command); await _mediator.Send(command); } }
public async Task <IActionResult> CancelOrder([FromBody] CancelOrderCommand command) { _logger.LogInformation( "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", command.GetGenericTypeName(), nameof(command.OrderNumber), command.OrderNumber, command); var commandResult = await _mediator.Send(command); if (!commandResult) { return(BadRequest()); } return(Ok()); }
public async Task Handle(OrderCouponRejectedIntegrationEvent @event) { using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) { Log.Information("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); Log.Warning("Discount failed, cancelling order {OrderId}", @event.OrderId); var command = new CancelOrderCommand(@event.OrderId); Log.Information("----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})", command.GetGenericTypeName(), nameof(command.OrderNumber), command.OrderNumber, command); await _mediator.Send(command); } }