Browse Source

identityroleappservice imrovements

pull/1600/head
Yunus Emre Kalkan 7 years ago
parent
commit
10b89c67c1
  1. 4
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/GetIdentityRolesInput.cs
  2. 14
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs
  3. 15
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs
  4. 17
      modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs
  5. 3
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js
  6. 4
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs
  7. 4
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs
  8. 3
      modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs

4
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; }
}
}

14
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<IdentityRoleDto, Guid, GetIdentityRolesInput, IdentityRoleCreateDto, IdentityRoleUpdateDto>
public interface IIdentityRoleAppService : IApplicationService
{
//TODO: remove after a better design
Task<List<IdentityRoleDto>> GetAllListAsync();
Task<ListResultDto<IdentityRoleDto>> GetListAsync();
Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input);
Task<IdentityRoleDto> GetAsync(Guid id);
Task<IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleUpdateDto input);
Task DeleteAsync(Guid id);
}
}

15
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs

@ -31,22 +31,11 @@ namespace Volo.Abp.Identity
);
}
public async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(GetIdentityRolesInput input) //TODO: Remove this method since it's not used
public async Task<ListResultDto<IdentityRoleDto>> GetListAsync()
{
var count = (int) await _roleRepository.GetCountAsync();
var list = await _roleRepository.GetListAsync();
return new PagedResultDto<IdentityRoleDto>(
count,
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list)
);
}
public async Task<List<IdentityRoleDto>> 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<IdentityRole>, List<IdentityRoleDto>>(list);
return new ListResultDto<IdentityRoleDto>(ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list));
}
[Authorize(IdentityPermissions.Roles.Create)]

17
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<IdentityRoleDto> GetAsync(Guid id)
public virtual Task<ListResultDto<IdentityRoleDto>> GetListAsync()
{
return _roleAppService.GetAsync(id);
return _roleAppService.GetListAsync();
}
[HttpGet]
public virtual Task<PagedResultDto<IdentityRoleDto>> GetListAsync(GetIdentityRolesInput input)
[Route("{id}")]
public virtual Task<IdentityRoleDto> 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<List<IdentityRoleDto>> GetAllListAsync()
{
return _roleAppService.GetAllListAsync();
}
}
}

3
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: [
{

4
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<List<IdentityRoleDto>, AssignedRoleViewModel[]>(roleDtoList);
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(roleDtoList.Items);
foreach (var role in Roles)
{

4
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<IdentityUserDto, UserInfoViewModel>(await _identityUserAppService.GetAsync(id));
Roles = ObjectMapper.Map<List<IdentityRoleDto>, AssignedRoleViewModel[]>(
await _identityRoleAppService.GetAllListAsync()
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(
(await _identityRoleAppService.GetListAsync()).Items
);
var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList();

3
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);
}

Loading…
Cancel
Save