Exemplo n.º 1
0
        public async Task Handle(RequestMoneyDepositCommand message, IMessageHandlerContext context)
        {
            log.Info($"ENTRANDO A DEPOSITO, TransferId = {message.TransferId}");
            log.Info($"Received RequestMoneyDepositCommand, TransferId = {message.TransferId}");
            var nhibernateSession = context.SynchronizedStorageSession.Session();
            var transferAggregate = new Transfer(
                message.TransferId,
                new AccountId(message.DestinationAccountId),
                new AccountId(message.DestinationAccountId),
                Money.Dollars(message.Amount),
                TransferState.STARTED,
                message.Description,
                DateTime.UtcNow
                );

            nhibernateSession.Save(transferAggregate);
            var moneyTransferRequestedEvent = new MoneyDepositRequestedEvent
                                              (
                message.TransferId,
                message.DestinationAccountId,
                message.Amount,
                message.Description
                                              );
            await context.Publish(moneyTransferRequestedEvent);
        }
Exemplo n.º 2
0
 public async Task Handle(MoneyDepositRequestedEvent message, IMessageHandlerContext context)
 {
     log.Info($"MoneyTransferRequestedEvent, TransferId = {message.TransferId}");
     Data.TransferId           = message.TransferId;
     Data.DestinationAccountId = message.DestinationAccountId;
     Data.Amount = message.Amount;
     var command = new DepositMoneyCommand(
         Data.DestinationAccountId,
         Data.TransferId,
         Data.Amount
         );
     await context.Send(command).ConfigureAwait(false);
 }