コード例 #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);
 }