Example #1
0
        public ActionResult LoadFunctionsWithPermissionForMenu()
        {
            var FilterDefinition = new
            {
                ApplicationID = string.Empty,
                MenuSysNo     = 0
            };
            string json = Request["data"];

            var Filter = JsonConvert.DeserializeAnonymousType(json, FilterDefinition);

            List <SysFunction>   functions = SysMenuService.LoadAllFunctionsWithPermission(Filter.ApplicationID);
            List <SysPermission> has       = SysMenuService.LoadAllSysPermissionsByMenuSysNo(Filter.MenuSysNo);

            var result = from f in functions select new
            {
                id          = f.SysNo,
                text        = f.FunctionName,
                parent      = f.ParentSysNo,
                data        = f,
                parentcheck = false,
                options     = from p in f.Permissions select new {
                    id       = p.SysNo,
                    text     = p.PermissionName,
                    data     = p,
                    rootno   = f.ParentSysNo,
                    parentno = f.SysNo,
                    Default  = has.Exists(m => m.SysNo == p.SysNo)
                }
            };

            return(Json(new AjaxResult {
                Success = true, Data = result
            }, JsonRequestBehavior.AllowGet));
        }