public ActionResult Create(TransactionModel transaction)
        {
            if (ModelState.IsValid)
            {
                transaction.Username = User.Identity.Name;
                transactionsDb.Transactions.Add(transaction);
                transactionsDb.SaveChanges();

                UpdateBalanceAfterAddingTransaction(transaction);

                return RedirectToAction("Index");
            }

            return View(transaction);
        }
 /// <summary>
 /// Update the balance attribute once a transaction is removed
 /// </summary>
 /// <param name="transaction">The transaction to be removed</param>
 private void UpdateBalanceAfterRemovingTransaction(TransactionModel transaction)
 {
     var user = from u in usersDb.UsersDB
                where u.Username.Equals(User.Identity.Name)
                select u;
     var userModel = user.ToArray();
     if (transaction.TransactionType.Equals("Income"))
         userModel[0].Balance -= transaction.Amount;
     else
         userModel[0].Balance += transaction.Amount;
     usersDb.SaveChanges();
 }
        public ActionResult Edit(TransactionModel transaction)
        {
            if (ModelState.IsValid)
            {
                transaction.Username = User.Identity.Name;
                transactionsDb.Entry(transaction).State = EntityState.Modified;
                transactionsDb.SaveChanges();

                UpdateBalanceAfterAddingTransaction(transaction);

                return RedirectToAction("Index");
            }

            return View(transaction);
        }