public async Task Handle(PaymentRequestedEvent message, IMessageHandlerContext context)
 {
     Data.TransferId      = message.TransactionId;
     Data.SourceAccountId = message.CreditCardId;
     Data.Amount          = message.Amount;
     var command = new CreditCards.Messages.Commands.WithdrawMoneyCommand(
         Data.SourceAccountId,
         Data.TransferId,
         Data.Amount,
         message.OrderId
         );
     await context.Send(command).ConfigureAwait(false);
 }
Esempio n. 2
0
        public async Task Handle(RequestPaymentCommand message, IMessageHandlerContext context)
        {
            var nhibernateSession = context.SynchronizedStorageSession.Session();
            var paymentAggregate  = new Payment(
                message.TransactionId,
                message.CreditCardId,
                message.OrderId,
                Money.Dollars(message.Amount),
                TransferState.STARTED,
                DateTime.UtcNow
                );

            nhibernateSession.Save(paymentAggregate);
            var paymentRequestedEvent = new PaymentRequestedEvent
                                        (
                message.TransactionId,
                message.CreditCardId,
                message.Amount,
                message.OrderId
                                        );
            await context.Publish(paymentRequestedEvent);
        }