示例#1
0
        public async Task Handle(RequestMoneyTransferCommand message, IMessageHandlerContext context)
        {
            log.Info($"ENTRANDO A PROCESAR RETIRO, TransferId = {message.TransferId}");
            log.Info($"Received RequestMoneyTransferCommand, TransferId = {message.TransferId}");
            var nhibernateSession = context.SynchronizedStorageSession.Session();
            var transferAggregate = new Transfer(
                message.TransferId,
                new AccountId(message.SourceAccountId),
                new AccountId(message.DestinationAccountId),
                Money.Dollars(message.Amount),
                TransferState.STARTED,
                message.Description,
                DateTime.UtcNow
                );

            log.Info($"new AccountId(message.SourceAccountId) = {new AccountId(message.SourceAccountId)}");
            log.Info($"new AccountId(message.DestinationAccountId) = {new AccountId(message.DestinationAccountId)}");
            nhibernateSession.Save(transferAggregate);
            var moneyTransferRequestedEvent = new MoneyTransferRequestedEvent
                                              (
                message.TransferId,
                message.SourceAccountId,
                message.DestinationAccountId,
                message.Amount,
                message.Description
                                              );
            await context.Publish(moneyTransferRequestedEvent);
        }
示例#2
0
 public async Task Handle(RequestMoneyTransferCommand message, IMessageHandlerContext context)
 {
     //var transferAggregate = new Transfer('4b273d4d-7d89-4d0c-bb31-94827481e1db', '123-456-002', '123 - 456 - 003',500,'STARTED',null, DateTime.UtcNow);
     try
     {
         log.Info($"Received RequestMoneyTransferCommand, TransferId = {message.TransferId}");
         var nhibernateSession = context.SynchronizedStorageSession.Session();
         var transferAggregate = new Transfer(
             message.TransferId,
             new AccountId(message.SourceAccountId),
             new AccountId(message.DestinationAccountId),
             Money.Dollars(message.Amount),
             TransferState.STARTED,
             message.Description,
             DateTime.UtcNow
             );
         nhibernateSession.Save(transferAggregate);
         var moneyTransferRequestedEvent = new MoneyTransferRequestedEvent
                                           (
             message.TransferId,
             message.SourceAccountId,
             message.DestinationAccountId,
             message.Amount,
             message.Description
                                           );
         await context.Publish(moneyTransferRequestedEvent);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
示例#3
0
 public async Task Handle(MoneyTransferRequestedEvent message, IMessageHandlerContext context)
 {
     log.Info($"MoneyTransferRequestedEvent, TransferId = {message.TransferId}");
     Data.TransferId           = message.TransferId;
     Data.SourceAccountId      = message.SourceAccountId;
     Data.DestinationAccountId = message.DestinationAccountId;
     Data.Amount = message.Amount;
     var command = new WithdrawMoneyCommand(
         Data.SourceAccountId,
         Data.TransferId,
         Data.Amount
         );
     await context.Send(command).ConfigureAwait(false);
 }