public async Task Handle(DepositMoneyCommand message, IMessageHandlerContext context) { log.Info($"DepositMoneyCommand, TransferId = {message.TransactionId}"); var nhibernateSession = context.SynchronizedStorageSession.Session(); var accountAggregate = nhibernateSession.Get <Account>(message.AccountId); if (accountAggregate == null) { var destinationAccountNotFoundEvent = new DestinationAccountNotFoundEvent(message.TransactionId); await context.Publish(destinationAccountNotFoundEvent); } else { accountAggregate.DepositMoney(message.Amount); accountAggregate.ChangeUpdateAtUtc(); nhibernateSession.Save(accountAggregate); var moneyDepositedEvent = new MoneyDepositedEvent ( message.AccountId, message.TransactionId, message.Amount, accountAggregate.Balance.Amount, accountAggregate.Sobregiro_disponible.Amount ); await context.Publish(moneyDepositedEvent); } }
public async Task Handle(MoneyDepositedEvent message, IMessageHandlerContext context) { log.Info($"MoneyDepositedEvent, TransactionId = {message.TransactionId}"); var command = new CompleteMoneyTransferCommand( Data.TransferId ); await context.SendLocal(command).ConfigureAwait(false); MarkAsComplete(); }
private void Apply(MoneyDepositedEvent e) { Amount += e.Amount; }
public async Task <ActionResult> DepositMoney(MoneyDepositedEvent depositEvent) { var response = await _eventStoreRepo.AddEventAsync(depositEvent.AccountNumber, depositEvent); return(CreatedAtAction("created", response)); }