Пример #1
0
        public ActionResult edit(HT_TieuChi tc, string guiid)
        {
            if (String.IsNullOrEmpty(tc.NoiDung))
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Missing info"
                }, JsonRequestBehavior.AllowGet));
            }

            var check = db.HT_TieuChi.Where(p => p.IDTieuChuan == guiid && p.IDTieuChi == tc.IDTieuChi && p.GuiID == tc.GuiID).FirstOrDefault();

            if (check == null)
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Không tìm thấy thông tin"
                }, JsonRequestBehavior.AllowGet));
            }

            check.IDTieuChuan = tc.IDTieuChuan;
            check.NoiDung     = tc.NoiDung;

            db.Entry(check).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(Json(new ResultInfo()
            {
                error = 0, msg = "", data = check
            }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult create(HT_TieuChi tc, string guiid)
        {
            if (String.IsNullOrEmpty(tc.NoiDung))
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Missing info"
                }, JsonRequestBehavior.AllowGet));
            }

            var check = db.HT_TieuChi.Where(p => p.IDTieuChuan == guiid && p.IDTieuChi == tc.IDTieuChi).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

            tc.GuiID       = Guid.NewGuid().ToString();
            tc.IDTieuChuan = guiid;
            db.HT_TieuChi.Add(tc);
            db.SaveChanges();

            return(Json(new ResultInfo()
            {
                error = 0, msg = "", data = tc
            }, JsonRequestBehavior.AllowGet));
        }