public ActionResult editth(DM_LopHocTH th) { if (String.IsNullOrEmpty(th.NamHoc)) { return(Json(new ResultInfo() { error = 1, msg = "Missing info" }, JsonRequestBehavior.AllowGet)); } var check = db.DM_LopHocTH.Where(p => p.MaTruong == MaTruong && p.NamHoc == th.NamHoc).FirstOrDefault(); if (check == null) { return(Json(new ResultInfo() { error = 1, msg = "Không tìm thấy thông tin" }, JsonRequestBehavior.AllowGet)); } check.Lop1 = th.Lop1; check.Lop2 = th.Lop2; check.Lop3 = th.Lop3; check.Lop4 = th.Lop4; check.Lop5 = th.Lop5; db.Entry(check).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Json(new ResultInfo() { error = 0, msg = "", data = th }, JsonRequestBehavior.AllowGet)); }
public ActionResult createth(DM_LopHocTH th) { if (String.IsNullOrEmpty(th.NamHoc)) { return(Json(new ResultInfo() { error = 1, msg = "Missing info" }, JsonRequestBehavior.AllowGet)); } var check = db.DM_LopHocTH.Where(p => p.MaTruong == MaTruong && p.NamHoc == th.NamHoc).FirstOrDefault(); if (check != null) { return(Json(new ResultInfo() { error = 1, msg = "Đã tồn tại" }, JsonRequestBehavior.AllowGet)); } th.MaTruong = MaTruong; db.DM_LopHocTH.Add(th); db.SaveChanges(); return(Json(new ResultInfo() { error = 0, msg = "", data = th }, JsonRequestBehavior.AllowGet)); }