|
|
@ -4,7 +4,9 @@ using System.Threading.Tasks; |
|
|
using Blazorise; |
|
|
using Blazorise; |
|
|
using Blazorise.DataGrid; |
|
|
using Blazorise.DataGrid; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
|
|
using Volo.Abp.Data; |
|
|
using Volo.Abp.Identity; |
|
|
using Volo.Abp.Identity; |
|
|
|
|
|
using Volo.Abp.ObjectExtending; |
|
|
|
|
|
|
|
|
namespace MyCompanyName.MyProjectName.Blazor.Pages |
|
|
namespace MyCompanyName.MyProjectName.Blazor.Pages |
|
|
{ |
|
|
{ |
|
|
@ -14,13 +16,20 @@ namespace MyCompanyName.MyProjectName.Blazor.Pages |
|
|
{ |
|
|
{ |
|
|
private int _currentPage; |
|
|
private int _currentPage; |
|
|
private int? _totalCount; |
|
|
private int? _totalCount; |
|
|
|
|
|
|
|
|
private IReadOnlyList<IdentityRoleDto> _roles; |
|
|
private IReadOnlyList<IdentityRoleDto> _roles; |
|
|
|
|
|
|
|
|
private IdentityRoleCreateDto _newRole; |
|
|
private IdentityRoleCreateDto _newRole; |
|
|
|
|
|
private Guid _editingRoleId; |
|
|
|
|
|
private IdentityRoleUpdateDto _editingRole; |
|
|
|
|
|
|
|
|
private Modal _createModal; |
|
|
private Modal _createModal; |
|
|
|
|
|
private Modal _editModal; |
|
|
|
|
|
|
|
|
public RoleManagement() |
|
|
public RoleManagement() |
|
|
{ |
|
|
{ |
|
|
_newRole = new IdentityRoleCreateDto(); |
|
|
_newRole = new IdentityRoleCreateDto(); |
|
|
|
|
|
_editingRole = new IdentityRoleUpdateDto(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync() |
|
|
protected override async Task OnInitializedAsync() |
|
|
@ -48,7 +57,7 @@ namespace MyCompanyName.MyProjectName.Blazor.Pages |
|
|
StateHasChanged(); |
|
|
StateHasChanged(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async Task OpenCreateModalAsync() |
|
|
private void OpenCreateModal() |
|
|
{ |
|
|
{ |
|
|
_newRole = new IdentityRoleCreateDto(); |
|
|
_newRole = new IdentityRoleCreateDto(); |
|
|
_createModal.Show(); |
|
|
_createModal.Show(); |
|
|
@ -59,6 +68,31 @@ namespace MyCompanyName.MyProjectName.Blazor.Pages |
|
|
_createModal.Hide(); |
|
|
_createModal.Hide(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task OpenEditModalAsync(Guid id) |
|
|
|
|
|
{ |
|
|
|
|
|
var role = await RoleAppService.GetAsync(id); |
|
|
|
|
|
|
|
|
|
|
|
_editingRoleId = id; |
|
|
|
|
|
|
|
|
|
|
|
//TODO: User AutoMapper!
|
|
|
|
|
|
_editingRole = new IdentityRoleUpdateDto |
|
|
|
|
|
{ |
|
|
|
|
|
Name = role.Name, |
|
|
|
|
|
ConcurrencyStamp = role.ConcurrencyStamp, |
|
|
|
|
|
IsDefault = role.IsDefault, |
|
|
|
|
|
IsPublic = role.IsPublic |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
role.MapExtraPropertiesTo(_editingRole); |
|
|
|
|
|
|
|
|
|
|
|
_editModal.Show(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void CloseEditModal() |
|
|
|
|
|
{ |
|
|
|
|
|
_editModal.Hide(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private async Task CreateRoleAsync() |
|
|
private async Task CreateRoleAsync() |
|
|
{ |
|
|
{ |
|
|
await RoleAppService.CreateAsync(_newRole); |
|
|
await RoleAppService.CreateAsync(_newRole); |
|
|
@ -66,6 +100,13 @@ namespace MyCompanyName.MyProjectName.Blazor.Pages |
|
|
_createModal.Hide(); |
|
|
_createModal.Hide(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task UpdateRoleAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
await RoleAppService.UpdateAsync(_editingRoleId, _editingRole); |
|
|
|
|
|
await GetRolesAsync(); |
|
|
|
|
|
_editModal.Hide(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private async Task DeleteRoleAsync(Guid id) |
|
|
private async Task DeleteRoleAsync(Guid id) |
|
|
{ |
|
|
{ |
|
|
await RoleAppService.DeleteAsync(id); |
|
|
await RoleAppService.DeleteAsync(id); |
|
|
|