public ActionResult AddNewStudentClass(StudentClass model) { ViewBag.AlreadyExists = false; if (ModelState.IsValid) { if (model.Id != 0) { bool IsUpdated = StudentClass.Update(model.Id, model.Name); if (IsUpdated) { return(RedirectToAction("Index")); } } else { bool isAdded = StudentClass.AddNew(model.Name, ApplicationHelper.LoggedUserId); if (isAdded) { return(RedirectToAction("Index")); } } ViewBag.AlreadyExists = true; return(View(model)); } else { return(View(model)); } }