Beispiel #1
0
        private static string GetCategoryDescription(MenuCategory category)
        {
            var fieldInfo   = category.GetType().GetField(category.ToString());
            var description = fieldInfo
                              .GetCustomAttributes(typeof(DescriptionAttribute), false)
                              .Cast <DescriptionAttribute>()
                              .FirstOrDefault()?.Description;

            return(description ?? category.ToString());
        }
Beispiel #2
0
        public static MenuItemViewModel GetMenuItemsByMenuCategory(MenuCategory topMenucategory, MenuCategory leftMenuCategory, bool isAdvancedGrid)
        {
            ICachingService   cachingService     = IoC.Container.GetInstance <ICachingService>();
            var               result             = new List <MenuItem>();
            var               usersPermissions   = cachingService.GetUserPermissions(Thread.CurrentPrincipal.Identity.ToAccountID());
            var               accountPermissions = cachingService.GetAccountPermissions(Thread.CurrentPrincipal.Identity.ToAccountID());
            var               userModules        = usersPermissions.Where(s => s.RoleId == (short)Thread.CurrentPrincipal.Identity.ToRoleID() && accountPermissions.Contains(s.ModuleId)).Select(r => r.ModuleId).ToList();
            MenuItemViewModel viewModel          = new MenuItemViewModel();

            if (leftMenuCategory == MenuCategory.LeftMenuAccountSettings)
            {
                viewModel.IsAccountSettings = true;
            }
            var menus = new MenuService().GetMenu(topMenucategory.ToString(), leftMenuCategory.ToString(), userModules);

            if (isAdvancedGrid)
            {
                menus = menus.Where(w => w.MenuID != 1 && w.MenuID != 2).ToList();
            }
            foreach (var parentItem in menus.Where(mi => mi.ParentMenuID.Equals(null)))
            {
                result.Add(parentItem);
                var currentItem = (MenuItem)parentItem;
                foreach (var childItem in menus.Where(ci => ci.ParentMenuID == parentItem.MenuID).OrderBy(c => c.SortingID))
                {
                    result.Find(r => r.MenuId == currentItem.MenuId).Children.Add(childItem);
                }
            }
            result.OrderBy(o => o.SortingId).ToList();
            viewModel.TopMenuItems  = result.GroupBy(s => s.Category).Where(s => s.Key == topMenucategory).SelectMany(group => group).OrderBy(group => group.SortingId).ToList();
            viewModel.LeftMenuItems = result.GroupBy(s => s.Category).Where(s => s.Key == leftMenuCategory).SelectMany(group => group).OrderBy(group => group.SortingId).ToList();
            return(viewModel);
        }
Beispiel #3
0
 public String getMenuName()
 {
     return(string.Format("dz191.vhr.{0}.{1}.{2}{3}",
                          MCategory.ToString().ToLower(),
                          MajorCategory.ToString().ToLower(),
                          MinorCategory.ToString().ToLower(),
                          ExtraOptions != null?ExtraOptions.ToLower():""));
 }