public ActionResult Edit(int id, EditViewModel m) { try { // TODO: Add update logic here if (ModelState.IsValid) { var data = iModelRepositery.GetDetail(id); if (data != null) { int modelId = iModelRepositery.Update(m); return(RedirectToAction("Details", new { id = modelId })); } ViewBag.Name = "Model"; return(View("ProductNotFound", id)); } ViewBag.Companies = util.GetAllCompany(); ModelState.AddModelError("", "Something Went Wrong"); return(View(m)); } catch (Exception e) { ViewBag.Companies = util.GetAllCompany(); ModelState.AddModelError("", e.Message); return(View(m)); } }