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