private TagBuilder GetDropDownMenu() { TagBuilder dropdown = new TagBuilder("div"); dropdown.AddCssClass("dropdown mr-2 col"); if (UserIdentity.IsAuthenticated) { var menuItems = menuManager.GetMenuItems(UserIdentity.Name); TagBuilder dropdownToggle = new TagBuilder("a"); dropdownToggle.AddCssClass("text-white dropdown-toggle"); dropdownToggle.Attributes.Add("data-toggle", "dropdown"); dropdownToggle.InnerHtml.Append(UserIdentity.Name); TagBuilder dropdownMenu = new TagBuilder("div"); dropdownMenu.AddCssClass("dropdown-menu dropdown-menu-right"); foreach (var menuItem in menuItems) { TagBuilder item = new TagBuilder("a"); item.AddCssClass("dropdown-item"); item.InnerHtml.Append(menuItem.Name); item.Attributes["href"] = urlHelper.Action(menuItem.Action, menuItem.Controller); dropdownMenu.InnerHtml.AppendHtml(item); } dropdown.InnerHtml.AppendHtml(dropdownToggle); dropdown.InnerHtml.AppendHtml(dropdownMenu); TagBuilder userDiv = new TagBuilder("div"); userDiv.AddCssClass("text-right"); } return(dropdown); }
public IEnumerable <MenuItemDto> GetMenuItems() { return(ExecuteWithExceptionHandling(() => _menuManager.GetMenuItems())); }