Exemple #1
0
        public OperationResult GetByRoot(MenuType mType = MenuType.Menu, MenuUse menuUse = MenuUse.PC)
        {
            String          parentName = "root";
            OperationResult or = new OperationResult(OperationResultType.Error);
            Int32           use = menuUse.GetInt32(), mt = mType.GetInt32();
            List <ExtTreeData <Menu, String> > items = this.Entities.Where(c => c.Use == use && c.MType == mt && c.ParentName == parentName).Select(c => new ExtTreeData <Menu, String>()
            {
                id = c.ControllerName, text = c.Name, Tobject = c, expanded = false, leaf = true
            }).ToList();

            or = new OperationResult(OperationResultType.Success, "", items);
            return(or);
        }
Exemple #2
0
        public OperationResult GetByParentName(String parentName = "root", MenuType mType = MenuType.Menu, MenuUse menuUse = MenuUse.PC)
        {
            OperationResult   or = new OperationResult(OperationResultType.Error);
            Int32             use = menuUse.GetInt32(), mt = mType.GetInt32();
            IQueryable <Menu> menus = this.Entities.Where(c => c.Use == use && c.MType == mt);
            List <ExtTreeData <Menu, String> > items = menus.Where(p => p.ParentName == parentName).GroupJoin(
                menus, c => c.ControllerName, p => p.ParentName,
                (c, p) => new ExtTreeData <Menu, String>()
            {
                id = c.ControllerName, text = c.Name, Tobject = c, expanded = false, leaf = !(p.Count() > 0)
            }
                ).OrderBy(c => c.Tobject.Id).ToList();

            or = new OperationResult(OperationResultType.Success, "", items);
            return(or);
        }