Esempio n. 1
0
 public async Task Handle(MoneyWithdrawalRequestedEvent message, IMessageHandlerContext context)
 {
     log.Info($"SAGA MoneyWithdrawalRequestedEvent, TransferId = {message.TransferId}");
     Data.TransferId           = message.TransferId;
     Data.DestinationAccountId = message.DestinationAccountId;
     Data.Amount = message.Amount;
     var command = new WithdrawMoneyCommand(
         Data.DestinationAccountId,
         Data.TransferId,
         Data.Amount
         );
     await context.Send(command).ConfigureAwait(false);
 }
Esempio n. 2
0
        public async Task Handle(MoneyTransferRejectState message, IMessageHandlerContext context)
        {
            log.Info($"MoneyTransferRequestedEvent, EstadoId = {message.EstadoId}");
            Data.TransferId      = message.EstadoId;
            Data.SourceAccountId = message.SourceAccountId;

            Data.Amount = message.Amount;
            var command = new WithdrawMoneyCommand(
                Data.SourceAccountId,
                Data.TransferId,
                Data.Amount
                );
            await context.Send(command).ConfigureAwait(false);
        }
        public async Task <IActionResult> WithdrawMoney(WithdrawMoneyCommand command)
        {
            try
            {
                await _mediator.Send(command);

                return(Ok());
            }
            catch (ArgumentNullException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (ForbiddenCommandException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }