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