public bool Update(TbDotthi entity) { try { var dotthi = db.TbDotthis.SingleOrDefault(x => x.MaDT == entity.MaDT); dotthi.MaDT = entity.MaDT; dotthi.TenDT = entity.TenDT; dotthi.TrangThai = entity.TrangThai; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public ActionResult Create(TbDotthi dt) { var dao = new DtDao(); var id = dao.Insert(dt); if (id > 0) { SetAlert("Thêm đợt thi mới thành công", "success"); return(RedirectToAction("Index", "Dt")); } else { ModelState.AddModelError("", "Thêm mới không thành công"); } return(View("Index")); }
public ActionResult Edit(TbDotthi dt) { if (ModelState.IsValid) { var dao = new DtDao(); var result = dao.Update(dt); if (result) { SetAlert("Sửa đợt thi thành công", "success"); return(RedirectToAction("Index", "Dt")); } else { ModelState.AddModelError("", "Cập nhật không thành công"); } } return(View("Index")); }
public int Insert(TbDotthi entity) { db.TbDotthis.Add(entity); db.SaveChanges(); return(entity.MaDT); }