Example #1
0
        public async Task <Income> InsertAsync(NewIncome newIncome)
        {
            var expenseOwner = await _expenseOwnerRepository.GetAll()
                               .FirstOrDefaultAsync(owner => owner.OwnerUserId == newIncome.ExpenseOwnerUserId).ConfigureAwait(false);

            if (expenseOwner == null)
            {
                throw new MxNotFoundException($"Expense Owner with id {newIncome.ExpenseOwnerUserId} does not exist");
            }

            var income = new Income(newIncome, expenseOwner.ExpenseOwnerId);

            _incomeRepository.Insert(income);
            await _incomeRepository.SaveChangesAsync().ConfigureAwait(false);

            return(income);
        }
Example #2
0
 /// <summary>
 /// Opens the form to allow the user to add a new income
 /// </summary>
 /// <param name="sender">Standard sender object</param>
 /// <param name="e">Standard event object</param>
 private void newIncomeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // If the instance is not already open
     if (NewIncome == null)
     {
         MdiChilrenSum++;
         NewIncome           = new InputINUI();
         NewIncome.MdiParent = this;
         NewIncome.Show();
         NewIncome.FormClosed += new FormClosedEventHandler(MdiChildClosed);
         NewIncome.FormClosed += new FormClosedEventHandler(NewIncomeClose);
     }
     // Forces the form to the front
     else
     {
         NewIncome.BringToFront();
     }
 }