Пример #1
0
        public static ClsReturnValues setMenus(ClsMenus obj)
        {
            ClsReturnValues lst = new ClsReturnValues();
            using (var db = new tdoEntities())
            {

                lst = db.uspAddEditMenus(obj.menuID,obj.menuName,obj.menuDesc, obj.createdByID,obj.menuRanking, obj.sessionID).FirstOrDefault();
            }
            return lst;
        }
        public JsonResult setMenus(string menuID, string menuName, string menuDesc, string menuRanking)
        {
            List<ClsUserDisplay> userDisplay = new List<ClsUserDisplay>();
            using (tdoEntities db = new tdoEntities())
            {
                userDisplay = db.uspGetUserDisplay(GetID()).ToList<ClsUserDisplay>();
            }
            List<string> editableForms = Restriction.GetEditableForms(userDisplay);
            List<string> addableForms = Restriction.GetAddableForms(userDisplay);

            if (int.Parse(menuID) == 0 && !addableForms.Contains("Menus"))
            {
                return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to add new records." });
            }
            else if (int.Parse(menuID) != 0 && !editableForms.Contains("Menus"))
            {
                return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to edit records." });
            }

            if (menuID == "") { menuID = "0"; }

            Guid Session = new Guid(GetSession()); //do not hard code session ID and createdbyID
            int _id = 0;
            try { _id = int.Parse(menuID.Trim()); }
            catch { }
            ClsMenus obj = new ClsMenus()
            {
                menuID = _id,
                menuName = menuName,
                menuDesc = menuDesc,
                menuRanking = int.Parse(menuRanking),
                createdByID = GetID(),
                sessionID = Session
            };
            ClsReturnValues k = Administration.setMenus(obj);
            return Json(new { id = k.ID, isSuccess = k.IsSuccess ?? false ? 1 : 0, msg = k.Response });
        }