Beispiel #1
0
 public void Debit(Money money)
 {
     if (money.Amount > _state.Balance)
     {
         throw new InvalidOperationException("Amount to be debited cannot be greater than account balance");
     }
     _state.Balance -= money.Amount;
     var @event = new AccountDebitedEvent(Id, _state.Balance, money.Amount);
     _accountBalanceDebitedEventListeners.ForEach(l => l.Handle(@event));
 }
 public void Handle(AccountDebitedEvent @event)
 {
     _repository.SaveAccountBalance(new AccountBalance { Id = @event.AggregateId, Balance = @event.Balance });
 }