Пример #1
0
                public bool IsMatched(string path, App.Shared.Navigation.NavigationKey key)
                {
                    var keys = navService.GetActiveKeys(path);

                    if (keys != null && keys.Contains(key))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
Пример #2
0
        //public static bool HasRole(this HtmlHelper html, Domain.Users.Roles role) {

        //    return AppService.Current.User.CurrentUser.IsInRole(role);

        //}


        /// <summary>
        /// Checks the Path portion of the current Request context and matches it to one or more navigation keys
        /// (one or more meaning both top and second level navigation matches)
        /// </summary>
        /// <param name="html">extension object</param>
        /// <param name="navKey">Navigation Key that we need to check for a matching path on</param>
        /// <param name="cssClass">CSS Class to return if the path matches the specified navigation key</param>
        /// <returns></returns>
        public static string IsSelectedByUrl(this HtmlHelper html, App.Shared.Navigation.NavigationKey navKey, string cssClass = null)
        {
            if (string.IsNullOrEmpty(cssClass))
            {
                cssClass = "active";
            }

            string path = html.ViewContext.RequestContext.HttpContext.Request.Path;

            if (AppService.Current.Navigation.IsMatched(path, navKey))
            {
                return(cssClass);
            }
            else
            {
                return(string.Empty);
            }
        }