public MvcHtmlString GetMenuBarPage(Nullable <int> ParentId) { StringBuilder sb = new StringBuilder(); SIContext db = new SIContext(); //get role id and role regarding to role bind this var userId = Convert.ToInt32(Env.GetUserInfo("userid")); var RoleId = Convert.ToInt32(Env.GetUserInfo("roleid")); var q = db.MenuPermissions.Include("Menu_MenuId").Where(i => i.RoleId == RoleId || i.UserId == userId).ToArray(); sb.Append("<ul class=\"sidebar-menu\">"); sb.Append("<li class=\"active\"> <a href=\"" + MicrosoftHelper.MSHelper.GetSiteRoot() + "/Home\"> <i class=\"fa fa-dashboard\"></i> <span>Dashboard</span> </a> </li>"); if (RoleId == 1) { //get role id here if admin then sb.Append("<li class=\"treeview\"> <a href=\"#\"> <i class=\"fa fa-th\"></i> <span>Menu Management</span> </a> <ul class=\"treeview-menu\"> <li><a href=\"" + MicrosoftHelper.MSHelper.GetSiteRoot() + "/Menu\"><i class=\"fa fa-angle-double-right\"></i> Menu List</a></li> <li><a href=\"" + MicrosoftHelper.MSHelper.GetSiteRoot() + "/Menu/Create\"><i class=\"fa fa-angle-double-right\"></i> Menu Create</a></li> </ul> </li>"); sb.Append("<li class=\"treeview\"> <a href=\"#\"> <i class=\"fa fa-th\"></i> <span>Menu Permission</span> </a> <ul class=\"treeview-menu\"> <li><a href=\"" + MicrosoftHelper.MSHelper.GetSiteRoot() + "/MenuPermission\"><i class=\"fa fa-angle-double-right\"></i> Permission List</a></li> <li><a href=\"" + MicrosoftHelper.MSHelper.GetSiteRoot() + "/MenuPermission/Create\"><i class=\"fa fa-angle-double-right\"></i> Create Permission By Role</a></li> </ul> </li>"); // } sb.Append(GetMenuBar(ParentId, q)); sb.Append("</ul>"); return(MvcHtmlString.Create(sb.ToString())); }
public MvcHtmlString GetMenuBarPage(Nullable <int> ParentId) { StringBuilder sb = new StringBuilder(); SIContext db = new SIContext(); //get role id and role regarding to role bind this var userId = Convert.ToInt32(Env.GetUserInfo("userid")); var RoleId = Convert.ToInt32(Env.GetUserInfo("roleid")); var q = db.MenuPermissions.Where(i => i.RoleId == RoleId || i.UserId == userId).ToArray(); sb.Append("<ul class=\"sidebar-menu\">"); sb.Append("<li class=\"active\"> <a href=\"" + MicrosoftHelper.MSHelper.GetSiteRoot() + "/Home\"> <i class=\"fa fa-dashboard\"></i> <span>Dashboard</span> </a> </li>"); if (RoleId == 1) { } sb.Append(GetMenuBar(ParentId, q)); sb.Append("</ul>"); return(MvcHtmlString.Create(sb.ToString())); }