Beispiel #1
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);
        }
Beispiel #2
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());
        }