예제 #1
0
        public void Withdraw(Amount amount)
        {
            if (amount.IsOver(AmountPolicy.Maximum))
            {
                Apply(new WithdrawalAmountExceeded(amount));

                return;
            }

            Apply(new AmountWithdrawn(amount));
        }
예제 #2
0
 public AmountWithdrawn(Amount amount)
 {
     Amount = amount;
 }
예제 #3
0
 public AmountDeposited(Amount amount)
 {
     Amount = amount;
 }
예제 #4
0
 public WithdrawalAmountExceeded(Amount amount)
 {
     Amount = amount;
 }
예제 #5
0
 private void When(AmountDeposited @event)
 {
     _amount = _amount.Add(@event.Amount);
 }
예제 #6
0
 private void When(AmountWithdrawn @event)
 {
     _amount = _amount.Substract(@event.Amount);
 }
예제 #7
0
 public void Deposit(Amount amount)
 {
     Apply(new AmountDeposited(amount));
 }
예제 #8
0
 public Account(Guid id)
 {
     _id = id;
     _eventRecorder = new EventRecorder();
     _amount = new Amount(0);
 }
예제 #9
0
 public Amount Substract(Amount amount)
 {
     return new Amount(Value - amount.Value);
 }
예제 #10
0
 public bool IsOver(Amount amount)
 {
     return Value > amount.Value;
 }
예제 #11
0
 public Amount Add(Amount amount)
 {
     return new Amount(Value + amount.Value);
 }