public ActionResult AddNewRating(Rating model) { ViewBag.AlreadyExists = false; ViewBag.AllSchools = new SelectList(School.GetAll(), "Id", "Name"); if (ModelState.IsValid) { if (model.Id != 0) { bool IsUpdated = Rating.Update(model.Id, model.SchoolId, model.RateValue, model.Description); if (IsUpdated) { return(RedirectToAction("Index")); } } else { bool isAdded = Rating.AddNew(model.SchoolId, model.RateValue, model.Description, ApplicationHelper.LoggedUserId); if (isAdded) { return(RedirectToAction("Index")); } } ViewBag.AlreadyExists = true; return(View(model)); } else { return(View(model)); } }