public ActionResult Create(Restrictions model) { try { if (model.RestrictionId == 0) { var obj = new Restrictions() { Restriction = model.Restriction }; db.tabRestrictions.Add(obj); db.SaveChanges(); return PartialView("Create"); } else { Restrictions rObj = db.tabRestrictions.Find(model.RestrictionId); rObj.Restriction = model.Restriction; db.Entry(rObj).State = EntityState.Modified; db.SaveChanges(); return PartialView("Create"); } } catch (Exception ex) { throw ex; } }
public ActionResult Edit(Restrictions re) { if (ModelState.IsValid) { var r = db.tabRestrictions.Find(re.RestrictionId); r.Restriction = re.Restriction; db.Entry(r).State = EntityState.Modified; db.SaveChanges(); } return PartialView(); }