public async Task Handle(DepositMoney depositMoney, IMessageHandlerContext context) { try { log.Info($"DepositMoneyHandler, TransactionId = {depositMoney.TransactionId}"); var nHibernateSession = context.SynchronizedStorageSession.Session(); var bankAccountId = BankAccountId.FromExisting(depositMoney.ToBankAccountId); var toBankAccount = nHibernateSession.Get <BankAccount>(bankAccountId) ?? BankAccount.NonExisting(); if (toBankAccount.DoesNotExist()) { var toBankAccountNotFound = new ToBankAccountNotFound(depositMoney.TransactionId); await context.Publish(toBankAccountNotFound); return; } toBankAccount.Deposit(depositMoney.Amount); toBankAccount.ChangeUpdatedAt(); nHibernateSession.Save(toBankAccount); var moneyDeposited = new MoneyDeposited ( depositMoney.TransactionId, toBankAccount.BankAccountId.Id, depositMoney.Amount, toBankAccount.Balance.Amount ); await context.Publish(moneyDeposited); } catch (Exception ex) { log.Error(ex.Message + " ** " + ex.StackTrace); } }
public async Task On(MoneyDeposited @event, long sequence) { var balance = await _repository.GetAsync(@event.Id); balance.Balance += @event.Amount; await _repository.UpdateBalance(balance, sequence); _logger.LogInformation( $"Money deposited from bank account {_repository.BankAccount}. New Balance: {balance.Balance}"); }
public void Deposit(decimal amount) { if (amount <= 0) { throw new IncorrectDepositAmountException(); } var @event = new MoneyDeposited( accountId: Id, amount: amount); Apply(@event); AddDomainEvent(@event); }
public void Handle(MoneyDeposited e) { if (e.Transaction == Guid.Empty) { return; } var status = new UpdateTransfer(e.Transaction, "Credit Succeeded"); _commander.Send(status); var complete = new CompleteTransfer(e.Transaction); _commander.Send(complete); }
private void Handle(MoneyDeposited evt) { var ci = indexer.Get <ClientInformation>(evt.ClientID); ci.Balance += evt.Quantity; ci.LastMovement = evt.TimeStamp; indexer.Index(ci); var ad = indexer.Get <AmountDepositedInTheBank>(evt.TransactionId.ToString()); if (ad == null) { indexer.Index(new AmountDepositedInTheBank { Quantity = evt.Quantity, TimeStamp = evt.TimeStamp, ID = evt.ClientID, TransactionId = evt.TransactionId }); } }
private void Apply(MoneyDeposited obj) { Balance += obj.Quantity; }
public void Handle(MoneyDeposited c) { _store.IncreaseAccountBalance(c.AggregateIdentifier, c.Amount); }
void IApply <MoneyDeposited> .Apply(MoneyDeposited @event) { balance += @event.Amount; }
private void When(MoneyDeposited @event) { balance += @event.Amount; }
/// <summary> /// Apply money deposited state changes. /// </summary> /// <param name="e">The money deposited event.</param> protected void Apply(MoneyDeposited e) { Balance = e.Balance; }
protected void Apply(MoneyDeposited moneyDeposited) { Balance += moneyDeposited.Amount; }
public void Handle(MoneyDeposited e) { }