public ActionResult RoleGridViewRoleUpdate(tcpjw3.oa.Models.webpages_Roles item) { var model = db.webpages_Roles; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.RoleId == item.RoleId); if (modelItem != null) { this.UpdateModel(modelItem); db.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_RoleGridViewRole", model.ToList())); }
public ActionResult RoleGridViewRoleAddNew([Bind(Include = "RoleName")] tcpjw3.oa.Models.webpages_Roles item) { var model = db.webpages_Roles; if (ModelState.IsValid) { try { model.Add(item); db.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_RoleGridViewRole", model.ToList())); }