public ActionResult Create(CTGRY_TBL categoryModel) { try { using (DMSDbEntities db = new DMSDbEntities()) { db.CTGRY_TBL.Add(categoryModel); db.SaveChanges(); return RedirectToAction("Index",db.CTGRY_TBL.ToList()); } } catch { return View(); } }
public ActionResult Edit(CTGRY_TBL categoryModel) { try { using (DMSDbEntities db = new DMSDbEntities()) { var entry = db.Entry<CTGRY_TBL>(categoryModel); if (entry.State.Equals(EntityState.Detached)) { db.CTGRY_TBL.Attach(categoryModel); } entry.State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index",db.CTGRY_TBL.ToList()); } } catch { return View(); } }
public ActionResult Delete(CTGRY_TBL categoryModel) { try { using (DMSDbEntities db = new DMSDbEntities()) { var entry = db.Entry<CTGRY_TBL>(categoryModel); entry.State = EntityState.Deleted; db.CTGRY_TBL.ToList().RemoveAll(p => p.CtgryId == categoryModel.CtgryId); db.SaveChanges(); return RedirectToAction("Index", db.CTGRY_TBL.ToList()); } } catch { return View(); } }