public ActionResult Create(lotrinh collection) { if (ModelState.IsValid) { var dao = new LoTrinhDao(); long id = dao.Insert(collection); if (id > 0) { return(RedirectToAction("Index", "LoTrinh")); } else { ModelState.AddModelError("", "Thêm không thành công"); } } return(View("Index")); }
public ActionResult Edit(int id, lotrinh collection) { if (ModelState.IsValid) { var dao = new LoTrinhDao(); var result = dao.Update(collection, id); if (result) { return(RedirectToAction("Index", "LoTrinh")); } else { ModelState.AddModelError("", "Cập nhật không thành công"); } } return(View("Index")); }
public bool Update(lotrinh entity, int id) { try { var data = db.lotrinhs.Find(id); data.kv_id = entity.kv_id; data.lt_ten = entity.lt_ten; data.nv_id = entity.nv_id; data.lt_ghichu = entity.lt_ghichu; db.SaveChanges(); return(true); } catch (Exception ex) { //logging return(false); } }
public int Insert(lotrinh entity) { db.lotrinhs.Add(entity); db.SaveChanges(); return(entity.lt_id); }
public ActionResult Delete(int id, lotrinh collection) { new LoTrinhDao().Delete(id); return(RedirectToAction("Index", "LoTrinh")); }