public ActionResult Add(DanhMucLon model) { using (var ctx = new QLDauGiaEntities()) { ctx.DanhMucLon.Add(model); ctx.SaveChanges(); } return(View()); }
public ActionResult Update(DanhMucLon model) { using (var ctx = new QLDauGiaEntities()) { ctx.Entry(model).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } return(RedirectToAction("XuatDanhMuc", "DanhMuc")); }
public ActionResult Delete(int idToDelete) { using (var ctx = new QLDauGiaEntities()) { DanhMucLon model = ctx.DanhMucLon .Where(c => c.ID == idToDelete) .FirstOrDefault(); model.TinhTrang = true; ctx.SaveChanges(); } return(RedirectToAction("XuatDanhMuc", "DanhMuc")); }
//hàm Edit ở đây public ActionResult Edit(int?id) { if (id.HasValue == false) { return(RedirectToAction("XuatDanhMuc", "DanhMuc")); } using (var ctx = new QLDauGiaEntities()) { DanhMucLon model = ctx.DanhMucLon .Where(c => c.ID == id) .FirstOrDefault(); return(View(model)); } }