Пример #1
0
        public List <PermissionMenu> GetMenu()
        {
            var permissionMenus   = _menuServices.QueryableToList(c => c.IsDel == 1 && c.MenuType == "menu" && c.Status == 1);
            var parentPermissions = permissionMenus.Where(a => a.MenuParent == -1).ToList();
            var ret = new List <PermissionMenu>();

            parentPermissions.ForEach(p =>
            {
                PermissionMenu permissionMenu = PermissionMenu.Create(p);
                permissionMenu.Children       = permissionMenus
                                                .Where(c => c.MenuParent == p.MenuId)
                                                .Select(m => new PermissionMenu()
                {
                    Id       = m.MenuId.ToString(),
                    Name     = m.MenuName,
                    Icon     = m.MenuIcon,
                    Url      = m.MenuUrl,
                    ParentId = m.MenuParent.ToString()
                }).ToList();
                ret.Add(permissionMenu);
            });
            return(ret);
        }