public ActionResult Create(expense expense) { try { subcategory subCat = SubCategoryRepository.GetBySubCategoryID(expense.subCategoryID); if (expense.bankAccountID == 0) { expense.bankAccountID = subCat.bankAccountID; } if (expense.Comment == null) { expense.Comment = ""; } if (ModelState.IsValid) { db.expenses.Add(expense); db.SaveChanges(); ExpenseRepository.AddRecord(expense); TempData["Message2"] = "Expense added successfully."; if (expense.PendingBillID > 0) { bill bill = db.bills.Find(expense.PendingBillID); bill.Status = "Processing"; db.SaveChanges(); BillRepository.AddRecord(bill); } GetData(); @ViewBag.ExpenseType = ""; return(RedirectToAction("Create", "Expense", new { payeeID = 0 })); } } catch (Exception ex) { TempData["Message2"] = "Error adding expense"; } GetData(); @ViewBag.ExpenseType = ""; return(PartialView(expense)); }