Ejemplo n.º 1
0
        public void AddExpense(decimal amount)
        {
            decimal balance = Deposit - amount;

            if (Deposit > 0m)
            {
                if (balance < 0)
                {
                    if (AccountOnRed != null)
                    {
                        AccountOnRed.Invoke(this, new EventArgsExt(amount, balance));
                    }
                }
                else
                {
                    Deposit = balance;

                    if (ExpenseAdded != null)
                    {
                        ExpenseAdded.Invoke(this, new EventArgsExt(amount, balance));
                    }
                }
            }
        }
 public Task Handle(ExpenseAdded notification, CancellationToken cancellationToken) =>
 _invoiceCollection.UpdateOneAsync(
     i => i.InvoiceId == notification.AggregateRootId.Id,
     Builders <InvoiceViewModel> .Update.Push(i => i.Expenses, new ExpenseViewModel()),
     cancellationToken: cancellationToken);