From 3e623ac2a5ca19fc6bf02ffeb7aca34523934b17 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 30 Apr 2025 11:57:06 +0800 Subject: [PATCH] Sort roles by name in GetRolesAsync and GetAssignableRolesAsync methods --- .../Volo/Abp/Identity/IdentityUserAppService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index a56935424e..582d9ade42 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; @@ -58,7 +59,7 @@ public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppSe { //TODO: Should also include roles of the related OUs. - var roles = await UserRepository.GetRolesAsync(id); + var roles = (await UserRepository.GetRolesAsync(id)).OrderBy(x => x.Name).ToList(); return new ListResultDto( ObjectMapper.Map, List>(roles) @@ -68,9 +69,8 @@ public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppSe [Authorize(IdentityPermissions.Users.Default)] public virtual async Task> GetAssignableRolesAsync() { - var list = await RoleRepository.GetListAsync(); - return new ListResultDto( - ObjectMapper.Map, List>(list)); + var list = (await RoleRepository.GetListAsync()).OrderBy(x => x.Name).ToList(); + return new ListResultDto(ObjectMapper.Map, List>(list)); } [Authorize(IdentityPermissions.Users.Create)]