public ActionResult Create(Expense expense) { try { if (ModelState.IsValid) { expense.StudentId = studentManager.GetAllStudents().Where(x => x.Email == User.Identity.Name).FirstOrDefault().StudentId; expense.ExpenseDate = DateTime.Now; expenseManager.Insert(expense); TempData["Msg1"] = "Expense amount saved successfully"; return(RedirectToAction("Index")); } else { return(View("Index")); } } catch (Exception e) { TempData["Msg"] = "Failed to save expense " + e.Message; return(RedirectToAction("Index")); } }