Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 public Task Handle(Transfer2Event @event)
 {
     //Handles events from aggregate but this domain doesn't do anything with them
     return(Task.CompletedTask);
 }
Beispiel #4
0
 protected void Apply(Transfer2Event @event)
 {
     Balance += @event.Amount;
     LastTransactionDescription = @event.Description;
     LastTransactionAmount      = @event.Amount;
 }