Esempio n. 1
0
        public static ClsReturnValues setMenuIcons(ClsMenuIcons obj)
        {
            ClsReturnValues lst = new ClsReturnValues();
            using (var db = new tdoEntities())
            {

                lst = db.uspAddEditMenuIcons(obj.menuIconID, obj.menuID, obj.menuIconName).FirstOrDefault();
            }
            return lst;
        }
        public JsonResult setMenuIcons(string menuIconID, string menuID, string menuIconName)
        {
            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(menuIconID) == 0 && !addableForms.Contains("MenuIcons"))
            {
                return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to add new records." });
            }
            else if (int.Parse(menuIconID) != 0 && !editableForms.Contains("MenuIcons"))
            {
                return Json(new { id = 0, isSuccess = false, msg = "You are not allowed to edit records." });
            }

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

            Guid Session = new Guid(GetSession()); //do not hard code session ID and createdbyID
            int _id = 0;
            try { _id = int.Parse(menuIconID.Trim()); }
            catch { }
            ClsMenuIcons obj = new ClsMenuIcons()
            {
                menuIconID = _id,
                menuID = int.Parse(menuID),
                menuIconName = menuIconName
            };
            ClsReturnValues k = Administration.setMenuIcons(obj);
            return Json(new { id = k.ID, isSuccess = k.IsSuccess ?? false ? 1 : 0, msg = k.Response });
        }