From bde9bae9f0ebea467a84be7c49dbf9c40d928f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 26 Aug 2020 10:22:47 +0300 Subject: [PATCH] Update RoleManagement.razor --- .../Pages/RoleManagement.razor | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) 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 7b83c21d5d..c315fd3a55 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 @@ -7,27 +7,48 @@

Role Management

- - @if (_roles != null) { -

Total role count: @_totalRoleCount

+

Total role count: @_roles.TotalCount

} +

Create New Role

+ + + + + @code { - private long _totalRoleCount = 0; - private IReadOnlyList _roles; + private IdentityRoleCreateDto _newRole = new IdentityRoleCreateDto(); + + PagedResultDto _roles; + + protected override async Task OnInitializedAsync() + { + await GetRolesAsync(); + } private async Task GetRolesAsync() { - var result = await RoleAppService.GetListAsync(new PagedAndSortedResultRequestDto()); - _totalRoleCount = result.TotalCount; - _roles = result.Items; + _roles = await RoleAppService.GetListAsync(new PagedAndSortedResultRequestDto()); + } + + 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