public ActionResult Edit(Company model) { model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); var repo = new CompanyRepository(); bool isexists = repo.IsFieldExists(repo.ConnectionString(), "mstAccCompany", "cmpUsercode", model.cmpUsercode, "cmpCode", model.cmpCode); if (!isexists) { var result = new CompanyRepository().UpdateCompany(model); if (result.cmpCode > 0) { TempData["Success"] = "Updated Successfully!"; TempData["cmpUsercode"] = result.cmpUsercode; return(RedirectToAction("Index")); } else { TempData["error"] = "Oops!!..Something Went Wrong!!"; TempData["cmpUsercode"] = null; return(View("Create", model)); } } else { TempData["error"] = "This Name Alredy Exists!!"; TempData["cmpUsercode"] = null; return(View("Create", model)); } }