コード例 #1
0
            public IList <MenuAccessLiteWithChildDTO> filterSuperAdminAccess(IList <MenuAccessLiteWithChildDTO> resListAccess)
            {
                for (int i = 0; i < resListAccess.Count(); i++)
                {
                    if (!resListAccess[i].IsSuperAdminOnly)
                    {
                        if (resListAccess[i].Children.Count > 0)
                        {
                            foreach (var item in resListAccess[i].Children)
                            {
                                if (!item.IsSuperAdminOnly && item.Children.Count > 0)
                                {
                                    foreach (var child in item.Children)
                                    {
                                        IList <MenuAccessLiteWithChildDTO> newChild2 = item.Children.Where(x => x.IsSuperAdminOnly == false).ToList();
                                        item.Children = null;
                                        item.Children = MenuAccessLiteWithChildDTO.From(newChild2).ToList();
                                    }
                                }
                            }
                            ;
                            IList <MenuAccessLiteWithChildDTO> newChild = resListAccess[i].Children.Where(x => x.IsSuperAdminOnly == false).ToList();
                            resListAccess[i].Children = null;
                            resListAccess[i].Children = MenuAccessLiteWithChildDTO.From(newChild).ToList();
                        }
                    }
                }
                ;

                IList <MenuAccessLiteWithChildDTO> newResListAccess = resListAccess.Where(x => x.IsSuperAdminOnly == false).ToList();

                return(newResListAccess);
            }
コード例 #2
0
        public IList <MenuAccessLiteWithChildDTO> GetByListControllerAndActionMenu(List <MenuAccessLiteParameters> model)
        {
            IList <Menu> menus       = _menuRepository.GetMenu().ToList();
            IList <Menu> menusResult = menus
                                       .Where(x => model.Any(y => (y.ControllerName.Equals(x.ControllerName) && y.ActionName.Equals(x.ActionName))))
                                       .ToList();

            return(MenuAccessLiteWithChildDTO.OrderedFrom(menusResult));
        }
コード例 #3
0
 public void AddChildren(MenuAccessLiteWithChildDTO node, List <Menu> source)
 {
     try
     {
         if (source.Where(x => x.Parent.Id == node.Id).Count() > 0)
         {
             List <Menu> mnChild = source.Where(x => x.Parent.Id == node.Id).ToList();
             IList <MenuAccessLiteWithChildDTO> childs = MenuAccessLiteWithChildDTO.From(mnChild);
             node.Children = childs;
             for (int i = 0; i < node.Children.Count; i++)
             {
                 AddChildren((MenuAccessLiteWithChildDTO)node.Children[i], source);
             }
         }
         else
         {
             node.Children = new List <MenuAccessLiteWithChildDTO>();
         }
     }
     catch (Exception x)
     {
         throw x;
     }
 }