Browse Source

role pages pagination

application and mvc
pull/2412/head
Yunus Emre Kalkan 7 years ago
parent
commit
167c7428d8
  1. 2
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs
  2. 10
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs
  3. 4
      modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs
  4. 7
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js
  5. 6
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs
  6. 6
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs
  7. 6
      modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs

2
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs

@ -8,7 +8,7 @@ namespace Volo.Abp.Identity
{
public interface IIdentityRoleAppService : IApplicationService
{
Task<ListResultDto<IdentityRoleDto>> GetListAsync();
Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input);
Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input);

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

@ -28,11 +28,15 @@ namespace Volo.Abp.Identity
);
}
public virtual async Task<ListResultDto<IdentityRoleDto>> GetListAsync()
public virtual async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
var list = await _roleRepository.GetListAsync();
var list = await _roleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount);
var totalCount = await _roleRepository.GetCountAsync();
return new ListResultDto<IdentityRoleDto>(ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list));
return new PagedResultDto<IdentityRoleDto>(
totalCount,
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list)
);
}
[Authorize(IdentityPermissions.Roles.Create)]

4
modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs

@ -20,9 +20,9 @@ namespace Volo.Abp.Identity
}
[HttpGet]
public virtual Task<ListResultDto<IdentityRoleDto>> GetListAsync()
public virtual Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
return _roleAppService.GetListAsync();
return _roleAppService.GetListAsync(input);
}
[HttpGet]

7
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/index.js

@ -14,9 +14,10 @@
var _dataTable = _$table.DataTable(abp.libs.datatables.normalizeConfiguration({
order: [[1, "asc"]],
searching:false,
paging:false,
info:false,
searching: false,
processing: true,
serverSide: true,
paging: true,
ajax: abp.libs.datatables.createAjax(_identityRoleAppService.getList),
columnDefs: [
{

6
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos;
namespace Volo.Abp.Identity.Web.Pages.Identity.Users
{
@ -27,7 +28,10 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
{
UserInfo = new UserInfoViewModel();
var roleDtoList = await _identityRoleAppService.GetListAsync();
var roleDtoList = await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto
{
MaxResultCount = int.MaxValue
});
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(roleDtoList.Items);

6
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs

@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.Identity.Web.Pages.Identity.Users
@ -30,7 +31,10 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await _identityUserAppService.GetAsync(id));
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(
(await _identityRoleAppService.GetListAsync()).Items
(await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto
{
MaxResultCount = int.MaxValue
})).Items
);
var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList();

6
modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading.Tasks;
using Xunit;
using Shouldly;
using Volo.Abp.Application.Dtos;
namespace Volo.Abp.Identity
{
@ -38,7 +39,10 @@ namespace Volo.Abp.Identity
{
//Act
var result = await _roleAppService.GetListAsync();
var result = await _roleAppService.GetListAsync(new PagedAndSortedResultRequestDto
{
MaxResultCount = int.MaxValue
});
//Assert

Loading…
Cancel
Save