private void AddUnauthenticatedItems(IList <INavigationSet> navigationSets)
        {
            ///ITERATE THROUGH THE NAV SETS, LOOKING FOR ONES THAT
            ///HAVE PAGES REQUIRING ZERO ROLES
            for (int i = 0; i < navigationSets.Count; i++)
            {
                var navigationSet = navigationSets[i];
                ///IF THE NAVIGATION SET CONTAINS ANY PAGES FOR UNAUTHENTICATED USERS
                ///THEN ADD BOTH THE NAVSET AND EACH OF ITS PAGES THAT ALLOWS FOR
                ///THIS.
                var navigationSetContainsUnauthenticatedItems =
                    (from p in navigationSet.Pages
                     where
                     //USER CAN ACCESS PAGE
                     NavigationHelper.CurrentUserCanAccessPage(p)
                     &&
                     //PAGE.BUTTON ISN'T HIDDEN
                     !p.HideNavButton

                     select p).Count() > 0;
                if (navigationSetContainsUnauthenticatedItems)
                {
                    //ADD THE NAVSET TO THE PANEL
                    AddNavigationSetViewModelToPanel(navigationSet);
                }
                else
                {
                    //CONTINUE ITERATING THROUGH NAV SETS
                    continue;
                }
            }
        }
        private void AddAuthenticatedItems(IList <INavigationSet> navigationSets)
        {
            ///ITERATE THROUGH THE NAV SETS, ADDING THE SETS AND
            ///THEIR CORRESPONDING PAGES WHICH THE CURRENT USER HAS
            ///THE ROLES TO USE.
            for (int i = 0; i < navigationSets.Count; i++)
            {
                var navigationSet            = navigationSets[i];
                var navSetContainsPageToShow =
                    //ANY PAGE IN NAVSET.PAGES
                    (from pge in navigationSet.Pages
                     where //WHERE...

                     //USER CAN ACCESS PAGE
                     NavigationHelper.CurrentUserCanAccessPage(pge)
                     &&
                     //PAGE.BUTTON ISN'T HIDDEN
                     !pge.HideNavButton

                     //IF THE COUNT IS > 0, THEN NAV SET CONTAINS A PAGE TO SHOW
                     select pge).Count() > 0;

                if (navSetContainsPageToShow)
                {
                    //ADD THE NAVSET TO THE PANEL
                    AddNavigationSetViewModelToPanel(navigationSet);
                }
                else
                {
                    //IF NO ROLES MATCH ANY PAGES IN THIS NAVSET
                    //THEN CONTINUE TO THE NEXT NAVSET ITERATION
                    continue;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Clears the child Page NavigationButtonViewModels, then populates
        /// them with pages according to the current user's roles and the
        /// page's required roles.
        /// </summary>
        public void PopulateNavigationButtonViewModels()
        {
            Items.Clear();
            if (NavigationSet == null)
            {
                return;
            }

            ///ADD ANY INDIVIDUAL PAGE THAT THE USER HAS A
            ///REQUIRED ROLE.
            for (int i = 0; i < NavigationSet.Pages.Count; i++)
            {
                var page = NavigationSet.Pages[i];
                if (NavigationHelper.CurrentUserCanAccessPage(page)
                    &&
                    !page.HideNavButton)
                {
                    var navButtonVM = new NavigationButtonViewModel(page);
                    ///THESE PAGES ARE ALREADY SORTED, SO WE CAN JUST
                    ///ADD THEM
                    Items.Add(navButtonVM);
                }
            }

            //RefreshItemsVisibility();
        }