Exemple #1
0
        public async Task Withdraw(decimal amount, string description)
        {
            if (amount < 0)
            {
                throw new ArgumentException("Invalid Amount");
            }

            await Rebuild();

            if (Balance - amount < 0)
            {
                throw new Exception("Insuffient Balance");
            }

            var @event = new Withdraw2Event()
            {
                AccountID   = ID,
                Amount      = amount,
                Description = description
            };

            await Append(@event);
        }
Exemple #2
0
 public Task Handle(Withdraw2Event @event)
 {
     //Handles events from aggregate but this domain doesn't do anything with them
     return(Task.CompletedTask);
 }
Exemple #3
0
 protected void Apply(Withdraw2Event @event)
 {
     Balance -= @event.Amount;
     LastTransactionDescription = @event.Description;
     LastTransactionAmount      = [email protected];
 }