Пример #1
0
 private static void BuildMenuTree(IList <Menu> items, MenuModels model)
 {
     foreach (var item in items.Where(x => x.ParentId == model.MenuBase.Id && x.Position == model.Position).OrderBy(p => p.Priority))
     {
         var level = model.Level + 1;
         var child = new MenuModels(item, model.Position, level);
         model.Items.Add(child);
         BuildMenuTree(items, child);
     }
 }
Пример #2
0
        public static void ResetMenu()
        {
            IList <MenuModels> menuTrees      = new List <MenuModels>();
            Company            currentCompany = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            string             key            = string.Format("{0}", currentCompany.TaxCode);

            MenuForCompany = new Dictionary <string, IList <MenuModels> >();
            IMenusService menuSrv  = IoC.Resolve <IMenusService>();
            IList <Menu>  ListMenu = menuSrv.ListActived(currentCompany.id);

            foreach (Menu item in ListMenu.Where(p => p.ParentId == 0).OrderBy(p => p.Priority))
            {
                var root = new MenuModels(item, item.Position);
                menuTrees.Add(root);
                BuildMenuTree(ListMenu, root);
            }
            MenuForCompany.Add(key, menuTrees);
        }
Пример #3
0
        public static IList <MenuModels> GetTree(int position)
        {
            IList <MenuModels> menuTrees      = new List <MenuModels>();
            Company            currentCompany = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            string             key            = string.Format("{0}", currentCompany.TaxCode);

            if (MenuForCompany != null && MenuForCompany.Keys.Contains(key))
            {
                menuTrees = MenuForCompany[key] as IList <MenuModels>;
                return(menuTrees.Where(p => p.Position == position).ToList());
            }
            MenuForCompany = new Dictionary <string, IList <MenuModels> >();
            IMenusService menuSrv  = IoC.Resolve <IMenusService>();
            IList <Menu>  ListMenu = menuSrv.ListActived(currentCompany.id);

            foreach (Menu item in ListMenu.Where(p => p.ParentId == 0).OrderBy(p => p.Priority))
            {
                var root = new MenuModels(item, item.Position);
                menuTrees.Add(root);
                BuildMenuTree(ListMenu, root);
            }
            MenuForCompany.Add(key, menuTrees);
            return(menuTrees.Where(p => p.Position == position).ToList());
        }