Esempio n. 1
0
        public async Task Handle(OrderPaymentSuccededIntegrationEvent @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 SetPaidOrderStatusCommand(@event.OrderId);

                _logger.LogInformation(
                    "----- Sending command: {CommandName} - {IdProperty}: {CommandId} ({@Command})",
                    command.GetGenericTypeName(),
                    nameof(command.OrderNumber),
                    command.OrderNumber,
                    command);

                await _mediator.Send(command);
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> SetPaidStatus([FromBody] SetPaidOrderStatusCommand command, [FromHeader(Name = "x-requestid")] string requestId)
        {
            bool result = false;

            if (Guid.TryParse(requestId, out Guid guid) && guid != Guid.Empty)
            {
                var requestCreateOrder = new IdentifiedCommand <SetPaidOrderStatusCommand, bool>(command, guid);
                result = await _mediator.Send(requestCreateOrder);
            }
            else
            {
                result = await _mediator.Send(command);
            }

            if (result)
            {
                return(Ok());
            }
            return(BadRequest());
        }
Esempio n. 3
0
 public async Task Handle(OrderPaymentSuccededIntegrationEvent @event)
 {
     var command = new SetPaidOrderStatusCommand(@event.OrderId);
     await _mediator.Send(command);
 }