示例#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));
 }
示例#2
0
 public void Credit(Money money)
 {
     _state.Balance += money.Amount;
     var @event = new AccountCreditedEvent(Id, _state.Balance, money.Amount);
     _accountBalanceCreditedEventListeners.ForEach(l => l.Handle(@event));
 }