Ejemplo n.º 1
0
        public static MvcHtmlString MvcIndexHtmlString(this HtmlHelper htmlhelper, string username)
        {
            var           menus = new UserLoginProvider().GetMenusByUserName(username);
            StringBuilder sb    = new StringBuilder();

            foreach (var d in menus)
            {
                MenusEnum menu = (MenusEnum)Enum.Parse(typeof(MenusEnum), d.Key);
                var       url  = menu.GetDescription();
                sb.AppendLine(" <li role=\"presentation\"><a href=\"" + url + "\">" + d.Key + "</a></li>");
            }
            return(MvcHtmlString.Create(sb.ToString()));
        }
Ejemplo n.º 2
0
        public static MvcHtmlString LeftMeunHtmlString(this HtmlHelper htmlhelper, string parent, string current, string username)
        {
            var           menus  = new UserLoginProvider().GetMenusByUserName(username);
            StringBuilder sb     = new StringBuilder();
            var           _menus = menus.FirstOrDefault(x => x.Key.Equals(parent, StringComparison.OrdinalIgnoreCase));

            if (_menus.Key != null)
            {
                foreach (var d in _menus.Value)
                {
                    MenusEnum menu = (MenusEnum)Enum.Parse(typeof(MenusEnum), d.Key);
                    var       url  = menu.GetDescription();
                    if (current.Equals(d.Key, StringComparison.OrdinalIgnoreCase))
                    {
                        sb.AppendLine(" <li><a href=\"" + url + "\" class=\"current\">" + d.Key + "</a></li>");
                    }
                    else
                    {
                        sb.AppendLine(" <li><a href=\"" + url + "\">" + d.Key + "</a></li>");
                    }
                }
            }
            return(MvcHtmlString.Create(sb.ToString()));
        }