コード例 #1
0
ファイル: Account.cs プロジェクト: vivianroberts/Banking
 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 Handle(AccountDebitedEvent @event)
 {
     _repository.SaveAccountBalance(new AccountBalance { Id = @event.AggregateId, Balance = @event.Balance });
 }