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

            var check = db.DM_ChucVu.Where(p => p.MaTruong == MaTruong && p.ID == chucvu.ID && p.NamHoc == NamHoc).FirstOrDefault();

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

            check.MaTruong = MaTruong;
            check.ID       = chucvu.ID;
            check.ChucVu   = chucvu.ChucVu;

            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(DM_ChucVu chucvu)
        {
            if (String.IsNullOrEmpty(chucvu.ChucVu))
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Missing info"
                }, JsonRequestBehavior.AllowGet));
            }

            var check = db.DM_ChucVu.Where(p => p.MaTruong == MaTruong && p.ID == chucvu.ID && p.NamHoc == NamHoc).FirstOrDefault();

            if (check != null)
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Đã tồn tại"
                }, JsonRequestBehavior.AllowGet));
            }
            chucvu.MaTruong = MaTruong;
            chucvu.NamHoc   = NamHoc;
            db.DM_ChucVu.Add(chucvu);

            db.SaveChanges();

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