public ActionResult ThemMoiCongDong(CongDong congdong) { ViewBag.MaCongDong = new SelectList(db.CongDongs.ToList().OrderBy(n => n.TenCongDong), "MaCongDong", "TenCongDong"); if (ModelState.IsValid) { db.CongDongs.InsertOnSubmit(congdong); db.SubmitChanges(); } return(RedirectToAction("CongDong", "Home")); }
public ActionResult SuaCongDong(CongDong congdong) { if (ModelState.IsValid) { var obj = db.CongDongs.SingleOrDefault(p => p.MaCongDong == congdong.MaCongDong); obj.TenCongDong = congdong.TenCongDong; db.SubmitChanges(); return(RedirectToAction("CongDong")); } ViewBag.MaCongDong = new SelectList(db.CongDongs.ToList().OrderBy(n => n.TenCongDong), "MaCongDong", "TenCongDong"); return(View(congdong)); }
public ActionResult XoaCongDong(int?id) { CongDong congdong = db.CongDongs.SingleOrDefault(n => n.MaCongDong == id); ViewBag.MaCongDong = congdong.MaCongDong; if (congdong == null) { Response.StatusCode = 404; return(null); } return(View(congdong)); }
public ActionResult SuaCongDong(int?id) { CongDong congdong = db.CongDongs.SingleOrDefault(n => n.MaCongDong == id); ViewBag.MaCongDong = congdong.MaCongDong; if (congdong == null) { Response.StatusCode = 404; return(null); } ViewBag.MaCongDong = new SelectList(db.CongDongs.ToList().OrderBy(n => n.TenCongDong), "MaCongDong", "TenCongDong", congdong.MaCongDong); return(View(congdong)); }
public ActionResult XacNhanXoaCongDong(int?id) { CongDong congdong = db.CongDongs.SingleOrDefault(n => n.MaCongDong == id); ViewBag.MaCongDong = congdong.MaCongDong; if (congdong == null) { Response.StatusCode = 404; return(null); } db.CongDongs.DeleteOnSubmit(congdong); db.SubmitChanges(); return(RedirectToAction("CongDong")); }