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); }
public Task Handle(Withdraw2Event @event) { //Handles events from aggregate but this domain doesn't do anything with them return(Task.CompletedTask); }
protected void Apply(Withdraw2Event @event) { Balance -= @event.Amount; LastTransactionDescription = @event.Description; LastTransactionAmount = [email protected]; }