本文整理汇总了C#中UserService.GetUserBrowse方法的典型用法代码示例。如果您正苦于以下问题:C# UserService.GetUserBrowse方法的具体用法?C# UserService.GetUserBrowse怎么用?C# UserService.GetUserBrowse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserService
的用法示例。
在下文中一共展示了UserService.GetUserBrowse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnAuthorization
public override void OnAuthorization(AuthorizationContext filterContext)
{
//ToTest
//int roleID = Convert.ToInt32(HttpContext.Current.Session["RoleID"]);
int roleID = 1;
UserService service = new UserService();
IEnumerable<UserBrowseViewModel> modules = service.GetUserBrowse(roleID);
foreach (UserBrowseViewModel module in modules)
{
filterContext.SetViewData(module.Code, module.Name);
}
}
示例2: CreateMenu
/// <summary>
/// 生成用户功能菜单
/// </summary>
public static MvcHtmlString CreateMenu(this HtmlHelper helper)
{
//HttpSessionState session = new HttpSessionState();
//session.Get("RoleId");
//ToTest
int roleID = 1;
string parentMenu = "<a href=\"#{0}\" class=\"nav-header\" data-toggle=\"collapse\"><i class=\"ico-menu ico-{1}\"></i>{2}</a>";
string childMenu = "<ul id=\"{0}\" class=\"nav nav-list collapse in pl20\">{1}</ul>";
string childContent = "<li><a target=\"content\" href=\"/{0}\"><i class=\"ico-menu ico-{1}\"></i>{2}</a></li>";
UserService userService = new UserService();
//获取可以浏览的菜单
IEnumerable<UserBrowseViewModel> modules = userService.GetUserBrowse(roleID);
//获取父菜单
IList<UserBrowseViewModel> parentModules = new List<UserBrowseViewModel>();
modules.Enumerate(m => m.ParentId == 0, m => parentModules.Add(m));
//获取子菜单
IEnumerable<T_Module> childModules = null;
StringBuilder menuBuilder = new StringBuilder();
StringBuilder childBuilder = new StringBuilder();
ModuleService moduleService = new ModuleService();
foreach (var parent in parentModules)
{
menuBuilder.AppendFormat(parentMenu, parent.Code + "-menu", parent.Code, parent.Name);
childModules = moduleService.GetChildModules(parent.ID);
foreach (var child in childModules)
{
childBuilder.AppendFormat(childContent, child.Url, child.Code, child.Name);
}
menuBuilder.AppendFormat(childMenu, parent.Code + "-menu", childBuilder.ToString());
childBuilder.Clear();
}
return MvcHtmlString.Create(menuBuilder.ToString());
}