Add operation executor
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
</RadzenColumn>
|
||||
<RadzenColumn Size="12" SizeMD="6">
|
||||
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.End" Gap="0.5rem">
|
||||
<RadzenButton Icon="add_circle_outline" Text="Создать" Click="@AddUser" ButtonStyle="ButtonStyle.Primary" />
|
||||
<RadzenButton Icon="add_circle_outline" Text="Создать" Click="@AddUserAsync" ButtonStyle="ButtonStyle.Primary" />
|
||||
</RadzenStack>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
@ -33,7 +33,7 @@
|
||||
<RadzenAlert Visible="@hasError" AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter" AllowClose="false">
|
||||
@errorMessage
|
||||
</RadzenAlert>
|
||||
<RadzenDataGrid TItem="AppUserWithRole" Data="@usersWithRoles" RowSelect="@EditUser" IsLoading="@isLoading" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true">
|
||||
<RadzenDataGrid TItem="AppUserWithRole" Data="@usersWithRoles" RowSelect="@EditUserAsync" IsLoading="@isLoading" AllowFiltering="true" AllowPaging="true" ShowPagingSummary="true" PageSizeOptions=@(new int[] { 5, 10, 20, 30 }) AllowSorting="true">
|
||||
<Columns>
|
||||
<RadzenDataGridColumn TItem="AppUserWithRole" Property="User.UserName" Title="Логин" />
|
||||
<RadzenDataGridColumn TItem="AppUserWithRole" Property="Role.Name" Title="Роль" />
|
||||
@ -41,7 +41,7 @@
|
||||
<Template Context="userWithRole">
|
||||
@if (userWithRole.User.Id != currentUserId)
|
||||
{
|
||||
<RadzenButton Click="@(() => DeleteUser(userWithRole))" @onclick:stopPropagation="true" ButtonStyle="ButtonStyle.Danger" Icon="close" Size="ButtonSize.Small" />
|
||||
<RadzenButton Click="@(() => DeleteUserAsync(userWithRole))" @onclick:stopPropagation="true" ButtonStyle="ButtonStyle.Danger" Icon="close" Size="ButtonSize.Small" />
|
||||
}
|
||||
</Template>
|
||||
</RadzenDataGridColumn>
|
||||
@ -74,7 +74,7 @@
|
||||
if (state.User.IsInRole(AppRole.ADMINISTRATOR_TYPE))
|
||||
{
|
||||
currentUserId = state.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||
usersWithRoles = await UsersService.GetUsersWithRole();
|
||||
usersWithRoles = await UsersService.GetUsersWithRoleAsync();
|
||||
}
|
||||
|
||||
isLoading = false;
|
||||
@ -83,7 +83,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
async Task AddUser()
|
||||
async Task AddUserAsync()
|
||||
{
|
||||
var success = await DialogService.OpenAsync<AddUser>(
|
||||
"Создание пользователя",
|
||||
@ -98,11 +98,11 @@
|
||||
|
||||
if (success)
|
||||
{
|
||||
await UpdateGrid();
|
||||
await UpdateGridAsync();
|
||||
}
|
||||
}
|
||||
|
||||
async Task EditUser(AppUserWithRole userWithRole)
|
||||
async Task EditUserAsync(AppUserWithRole userWithRole)
|
||||
{
|
||||
var success = await DialogService.OpenAsync<EditUser>(
|
||||
"Редактирование пользователя",
|
||||
@ -122,11 +122,11 @@
|
||||
|
||||
if (success)
|
||||
{
|
||||
await UpdateGrid();
|
||||
await UpdateGridAsync();
|
||||
}
|
||||
}
|
||||
|
||||
async Task DeleteUser(AppUserWithRole userWithRole)
|
||||
async Task DeleteUserAsync(AppUserWithRole userWithRole)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -141,10 +141,10 @@
|
||||
{
|
||||
isLoading = true;
|
||||
|
||||
var result = await UsersService.DeleteUser(userWithRole.User.Id);
|
||||
var result = await UsersService.DeleteUserAsync(userWithRole.User.Id);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
await UpdateGrid();
|
||||
await UpdateGridAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -162,12 +162,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
async Task UpdateGrid()
|
||||
async Task UpdateGridAsync()
|
||||
{
|
||||
isLoading = true;
|
||||
hasError = false;
|
||||
|
||||
usersWithRoles = await UsersService.GetUsersWithRole();
|
||||
usersWithRoles = await UsersService.GetUsersWithRoleAsync();
|
||||
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user