/// <summary> /// Initializes a new instance of the <see cref="SiteMapNodeModel"/> class. /// </summary> public SiteMapNodeModel() { RouteValues = new Dictionary <string, object>(); MetaAttributes = new Dictionary <string, string>(); Children = new SiteMapNodeModelList(); ShowOnlyInSiteMap = false; }
public static string MenuParentDisplay(this HtmlHelper htmlHelper, SiteMapNodeModelList nodes) { var currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString("action"); var currentController = htmlHelper.ViewContext.RouteData.GetRequiredString("controller"); var exists = nodes.Any(c => (string.Equals(c.Action, currentAction) && string.Equals(c.Controller, currentController))); return(exists ? "block" : "none"); }
public static bool CheckSubMenuPermission(this ControllerBase controller, SiteMapNodeModelList nodeList) { foreach (SiteMapNodeModel node in nodeList) { if (node.Attributes.Where(d => d.Key == "objectId").Count() > 0) { if (SECApplicationContext.SecurityContext.IsUserAuthorize(controller.ControllerContext.HttpContext.User.Identity.Name, node.Attributes["objectId"].ToString(), PermissionName.View.Value)) { return(true); } } } return(false); }
public static SiteMapNodeModel GetTopMenu(List <RoleInfo> menulist) { List <RoleInfo> topmenulist = new List <RoleInfo>(); SiteMapNodeModelList topMenuModelList = new SiteMapNodeModelList(); SiteMapNodeModelList childMenuModelList = new SiteMapNodeModelList(); if (menulist != null) { topmenulist = menulist.FindAll(p => p.ParentId == 0); } if (topmenulist != null) { foreach (RoleInfo tmenu in topmenulist) { childMenuModelList = new SiteMapNodeModelList(); foreach (RoleInfo pmenu in menulist.FindAll(p => p.ParentId == tmenu.Id)) { childMenuModelList.Add(new SiteMapNodeModel { Action = pmenu.Action, Controller = pmenu.Controller, Title = pmenu.Name, AppYN = pmenu.AppYN, //Description = pmenu.Description }); } topMenuModelList.Add(new SiteMapNodeModel { Action = tmenu.Action, Controller = tmenu.Controller, Title = tmenu.Name, AppYN = tmenu.AppYN, //Description = tmenu.Description, Children = childMenuModelList }); } } SiteMapNodeModelList result = new SiteMapNodeModelList(); result.Add(new SiteMapNodeModel { Children = topMenuModelList }); return(result.FirstOrDefault()); }
/// <summary> /// Initializes a new instance of the <see cref="SiteMapNodeModel"/> class. /// </summary> public SiteMapNodeModel() { RouteValues = new Dictionary<string, object>(); MetaAttributes = new Dictionary<string, string>(); Children = new SiteMapNodeModelList(); }