public ActionResult edit(DM_VietTat vt) { if (String.IsNullOrEmpty(vt.NoiDung) || String.IsNullOrEmpty(vt.VietTat)) { return(Json(new ResultInfo() { error = 1, msg = "Missing info" }, JsonRequestBehavior.AllowGet)); } var check = db.DM_VietTat.Where(p => p.MaTruong == MaTruong && p.VietTat == vt.VietTat).FirstOrDefault(); if (check == null) { return(Json(new ResultInfo() { error = 1, msg = "Không tìm thấy thông tin" }, JsonRequestBehavior.AllowGet)); } check.NoiDung = vt.NoiDung; check.VietTat = vt.VietTat; db.Entry(check).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Json(new ResultInfo() { error = 0, msg = "", data = check }, JsonRequestBehavior.AllowGet)); }
public ActionResult create(DM_VietTat vt) { if (String.IsNullOrEmpty(vt.NoiDung) || String.IsNullOrEmpty(vt.VietTat)) { return(Json(new ResultInfo() { error = 1, msg = "Missing info" }, JsonRequestBehavior.AllowGet)); } var check = db.DM_VietTat.Where(p => p.MaTruong == MaTruong && p.VietTat == vt.VietTat).FirstOrDefault(); if (check != null) { return(Json(new ResultInfo() { error = 1, msg = "Đã tồn tại" }, JsonRequestBehavior.AllowGet)); } //kiem tra neu la nam hoc hien tai thi xoa nhưng cai con lai vt.MaTruong = MaTruong; db.DM_VietTat.Add(vt); db.SaveChanges(); return(Json(new ResultInfo() { error = 0, msg = "", data = vt }, JsonRequestBehavior.AllowGet)); }