diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs index c5db3405a8..96c854c5b8 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs @@ -2,8 +2,8 @@ namespace Volo.Abp.Identity { - public class GetIdentityRolesInput : PagedAndSortedResultRequestDto + public class GetIdentityRolesInput { - public string Filter { get; set; } + } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs index 0d8f19f796..3fec60599d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs @@ -1,13 +1,21 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; namespace Volo.Abp.Identity { - public interface IIdentityRoleAppService : ICrudAppService + public interface IIdentityRoleAppService : IApplicationService { - //TODO: remove after a better design - Task> GetAllListAsync(); + Task> GetListAsync(); + + Task CreateAsync(IdentityRoleCreateDto input); + + Task GetAsync(Guid id); + + Task UpdateAsync(Guid id, IdentityRoleUpdateDto input); + + Task DeleteAsync(Guid id); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs index c91fc5ce1b..939d9739d2 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs @@ -31,22 +31,11 @@ namespace Volo.Abp.Identity ); } - public async Task> GetListAsync(GetIdentityRolesInput input) //TODO: Remove this method since it's not used + public async Task> GetListAsync() { - var count = (int) await _roleRepository.GetCountAsync(); var list = await _roleRepository.GetListAsync(); - return new PagedResultDto( - count, - ObjectMapper.Map, List>(list) - ); - } - - public async Task> GetAllListAsync() //TODO: Rename to GetList (however it's not possible because of the design of the IAsyncCrudAppService) - { - var list = await _roleRepository.GetListAsync(); - - return ObjectMapper.Map, List>(list); + return new ListResultDto(ObjectMapper.Map, List>(list)); } [Authorize(IdentityPermissions.Roles.Create)] diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs index ca11d75f48..0a45c00f50 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs @@ -21,16 +21,16 @@ namespace Volo.Abp.Identity } [HttpGet] - [Route("{id}")] - public virtual Task GetAsync(Guid id) + public virtual Task> GetListAsync() { - return _roleAppService.GetAsync(id); + return _roleAppService.GetListAsync(); } [HttpGet] - public virtual Task> GetListAsync(GetIdentityRolesInput input) + [Route("{id}")] + public virtual Task GetAsync(Guid id) { - return _roleAppService.GetListAsync(input); + return _roleAppService.GetAsync(id); } [HttpPost] @@ -52,12 +52,5 @@ namespace Volo.Abp.Identity { return _roleAppService.DeleteAsync(id); } - - [HttpGet] - [Route("all")] - public virtual Task> GetAllListAsync() - { - return _roleAppService.GetAllListAsync(); - } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js index 385b53f257..cde584cf20 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js @@ -14,6 +14,9 @@ var _dataTable = _$table.DataTable(abp.libs.datatables.normalizeConfiguration({ order: [[1, "asc"]], + searching:false, + paging:false, + info:false, ajax: abp.libs.datatables.createAjax(_identityRoleAppService.getList), columnDefs: [ { diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs index ce7a5a0507..4d36736501 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs @@ -28,9 +28,9 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users { UserInfo = new UserInfoViewModel(); - var roleDtoList = await _identityRoleAppService.GetAllListAsync(); + var roleDtoList = await _identityRoleAppService.GetListAsync(); - Roles = ObjectMapper.Map, AssignedRoleViewModel[]>(roleDtoList); + Roles = ObjectMapper.Map, AssignedRoleViewModel[]>(roleDtoList.Items); foreach (var role in Roles) { diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs index 0655331fb9..1b166b881f 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs @@ -30,8 +30,8 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users { UserInfo = ObjectMapper.Map(await _identityUserAppService.GetAsync(id)); - Roles = ObjectMapper.Map, AssignedRoleViewModel[]>( - await _identityRoleAppService.GetAllListAsync() + Roles = ObjectMapper.Map, AssignedRoleViewModel[]>( + (await _identityRoleAppService.GetListAsync()).Items ); var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList(); diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs index d20294da5c..03e872271f 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs @@ -38,11 +38,10 @@ namespace Volo.Abp.Identity { //Act - var result = await _roleAppService.GetListAsync(new GetIdentityRolesInput()); + var result = await _roleAppService.GetListAsync(); //Assert - result.TotalCount.ShouldBeGreaterThan(0); result.Items.Count.ShouldBeGreaterThan(0); }