public async Task TransferTo(Guid fromAccountID, decimal amount, string description) { if (amount < 0) { throw new ArgumentException("Invalid Amount"); } var @eventTo = new Transfer2Event() { AccountID = ID, FromAccountID = fromAccountID, Amount = amount, Description = description }; await Append(@eventTo, true); }
public async Task TransferFrom(Guid toAccountID, decimal amount, string description) { if (amount < 0) { throw new ArgumentException("Invalid Amount"); } await Rebuild(); if (Balance - amount < 0) { throw new Exception("Insuffient Balance"); } var @eventTo = new Transfer2Event() { AccountID = toAccountID, FromAccountID = ID, Amount = -amount, Description = description }; await Append(@eventTo, true); }
public Task Handle(Transfer2Event @event) { //Handles events from aggregate but this domain doesn't do anything with them return(Task.CompletedTask); }
protected void Apply(Transfer2Event @event) { Balance += @event.Amount; LastTransactionDescription = @event.Description; LastTransactionAmount = @event.Amount; }