Exemple #1
0
        public ActionResult delete(UMS_UserGroups group)
        {
            if (String.IsNullOrEmpty(group.GroupID))
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Missing info"
                }, JsonRequestBehavior.AllowGet));
            }

            var check = db.UMS_UserGroups.Where(p => p.MaTruong == MaTruong && p.GroupID == group.GroupID).FirstOrDefault();

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

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

            return(Json(new ResultInfo()
            {
                error = 0, msg = "", data = check
            }, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public ActionResult create(UMS_UserGroups group)
        {
            if (String.IsNullOrEmpty(group.GroupID))
            {
                return(Json(new ResultInfo()
                {
                    error = 1, msg = "Missing info"
                }, JsonRequestBehavior.AllowGet));
            }

            var check = db.UMS_UserGroups.Where(p => p.MaTruong == MaTruong && p.GroupID == group.GroupID).FirstOrDefault();

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

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