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