public void Withdraw(Amount amount) { if (amount.IsOver(AmountPolicy.Maximum)) { Apply(new WithdrawalAmountExceeded(amount)); return; } Apply(new AmountWithdrawn(amount)); }
public AmountWithdrawn(Amount amount) { Amount = amount; }
public AmountDeposited(Amount amount) { Amount = amount; }
public WithdrawalAmountExceeded(Amount amount) { Amount = amount; }
private void When(AmountDeposited @event) { _amount = _amount.Add(@event.Amount); }
private void When(AmountWithdrawn @event) { _amount = _amount.Substract(@event.Amount); }
public void Deposit(Amount amount) { Apply(new AmountDeposited(amount)); }
public Account(Guid id) { _id = id; _eventRecorder = new EventRecorder(); _amount = new Amount(0); }
public Amount Substract(Amount amount) { return new Amount(Value - amount.Value); }
public bool IsOver(Amount amount) { return Value > amount.Value; }
public Amount Add(Amount amount) { return new Amount(Value + amount.Value); }