diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/RoleManagement.razor b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/RoleManagement.razor index bff7a5e623..44dadebd9d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/RoleManagement.razor +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/RoleManagement.razor @@ -3,7 +3,6 @@ @using Volo.Abp.Identity @using Microsoft.AspNetCore.Authorization @using Microsoft.Extensions.Localization -@using Volo.Abp.Application.Dtos @using Volo.Abp.Identity.Localization @inject IIdentityRoleAppService RoleAppService @inject IStringLocalizer L @@ -11,9 +10,9 @@

@L["Roles"]

@@ -22,52 +21,4 @@ - - -@code { - - async Task OnReadGridData(DataGridReadDataEventArgs e) - { - currentPage = e.Page - 1; - await GetRolesAsync(); - StateHasChanged(); - } - - private IdentityRoleCreateDto _newRole = new IdentityRoleCreateDto(); - - int currentPage = 0; - readonly int pageSize = LimitedResultRequestDto.DefaultMaxResultCount; - int? totalCount = 0; - IReadOnlyList roles = Array.Empty(); - - protected override async Task OnInitializedAsync() - { - await GetRolesAsync(); - } - - private async Task GetRolesAsync() - { - var result = await RoleAppService.GetListAsync( - new PagedAndSortedResultRequestDto - { - SkipCount = currentPage * pageSize, - MaxResultCount = pageSize - }); - - roles = result.Items; - totalCount = (int?)result.TotalCount; - } - - private async Task CreateRoleAsync() - { - await RoleAppService.CreateAsync(_newRole); - _newRole = new IdentityRoleCreateDto(); - await GetRolesAsync(); - } - - private async Task DeleteRoleAsync(Guid id) - { - await RoleAppService.DeleteAsync(id); - await GetRolesAsync(); - } -} \ No newline at end of file + \ No newline at end of file diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/RoleManagement.razor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/RoleManagement.razor.cs new file mode 100644 index 0000000000..74fb85de70 --- /dev/null +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/RoleManagement.razor.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Blazorise.DataGrid; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Identity; + +namespace MyCompanyName.MyProjectName.Blazor.Pages +{ + //TODO: Idea: Can we create a base class to simplify all these, like CrudPage<...>..? + + public partial class RoleManagement + { + private int _currentPage; + private int? _totalCount; + private IReadOnlyList _roles; + private IdentityRoleCreateDto _newRole; + + public RoleManagement() + { + _newRole = new IdentityRoleCreateDto(); + } + + protected override async Task OnInitializedAsync() + { + await GetRolesAsync(); + } + + private async Task GetRolesAsync() + { + var result = await RoleAppService.GetListAsync( + new PagedAndSortedResultRequestDto + { + SkipCount = _currentPage * LimitedResultRequestDto.DefaultMaxResultCount, + MaxResultCount = LimitedResultRequestDto.DefaultMaxResultCount + }); + + _roles = result.Items; + _totalCount = (int?)result.TotalCount; + } + + private async Task OnDataGridReadAsync(DataGridReadDataEventArgs e) + { + _currentPage = e.Page - 1; + await GetRolesAsync(); + StateHasChanged(); + } + + private async Task CreateRoleAsync() + { + await RoleAppService.CreateAsync(_newRole); + _newRole = new IdentityRoleCreateDto(); + await GetRolesAsync(); + } + + private async Task DeleteRoleAsync(Guid id) + { + await RoleAppService.DeleteAsync(id); + await GetRolesAsync(); + } + } +}