public ActionResult Create(FormCollection collection,EXTN_TBL extenTblModel) { try { using (DMSDbEntities db = new DMSDbEntities()) { db.EXTN_TBL.Add(extenTblModel); db.SaveChanges(); return RedirectToAction("Index", db.EXTN_TBL.ToList()); } } catch { return View(); } }
public ActionResult Edit(int id, FormCollection collection,EXTN_TBL extnTblModel) { try { extnTblModel.EXTN_ID = id; using (DMSDbEntities db = new DMSDbEntities()) { var entry = db.Entry<EXTN_TBL>(extnTblModel); if (entry.State.Equals(EntityState.Detached)) { db.EXTN_TBL.Attach(extnTblModel); } entry.State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index", db.EXTN_TBL.ToList()); } } catch { return View(); } }
public ActionResult Delete(int id, FormCollection collection,EXTN_TBL extnTblModel) { try { using (DMSDbEntities db = new DMSDbEntities()) { extnTblModel = db.EXTN_TBL.FirstOrDefault(p => p.EXTN_ID == id); var entry = db.Entry<EXTN_TBL>(extnTblModel); entry.State = EntityState.Deleted; db.EXTN_TBL.ToList().RemoveAll(p => p.EXTN_ID == extnTblModel.EXTN_ID); db.SaveChanges(); return RedirectToAction("Index", db.EXTN_TBL.ToList()); } } catch { return View(); } }