public async Task GetRoleList(CommandContext ctx) { var userRoles = await _userRoleService.GetRoleList(); var sb = new StringBuilder(); sb.AppendLine("**List of roles**"); var roleGroups = userRoles .GroupBy(r => r.GroupNumber) .OrderBy(r => r.Key.HasValue ? r.Key : int.MaxValue); foreach (var roleGroup in roleGroups) { if (roleGroup.Key.HasValue) { sb.AppendLine($"Group number {roleGroup.Key.Value}"); } else { sb.AppendLine($"Ungrouped"); } foreach (var userRole in roleGroup.ToList()) { var formattedAliasList = string.Join(", ", userRole.UserRoleAliases.Select(x => x.Alias)); sb.AppendLine($"* {userRole.Name}: {formattedAliasList}"); } sb.AppendLine(); } var message = sb.ToString(); await ctx.RespondAsync(message); }
public async Task <List <SysRoles> > GetRoleList() { return(await _service.GetRoleList()); }