public ActionResult Create(ExpenseVM viewModel) { try { var UserProfile = (UserProfileSessionData)this.Session["UserProfile"]; if (UserProfile != null) { if (ModelState.IsValid) { tbl_ExpenseChannel item = new tbl_ExpenseChannel() { ShortName = viewModel.ShortName, ExpenseName = viewModel.ExpenseName, Expense = viewModel.Expense, ExpenseFactor = viewModel.ExpenseFactor, InsertDate = DateTime.Now, InsertUser = UserProfile.UserId }; CRUDOperation dataOperations = new CRUDOperation(); tbl_ExpenseChannel dbItem = dataOperations.AddExpenseChannel(item); if (dbItem != null) { TempData["success"] = "Ok"; TempData["message"] = "Məlumatlar uğurla əlavə olundu"; return(RedirectToAction("Index")); } else { TempData["success"] = "notOk"; TempData["message"] = "Məlumatlar əlavə olunarkən xəta baş verdi"; return(RedirectToAction("Index")); } } } throw new ApplicationException("Invalid model"); } catch (ApplicationException ex) { return(View(viewModel)); } }