@page "/management/users" @using Hcs.WebApp.Components.Dialogs @using Hcs.WebApp.Services @using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Identity @using Microsoft.EntityFrameworkCore @attribute [Authorize] @inject AuthenticationStateProvider AuthenticationStateProvider @inject UsersService UsersService @inject DialogService DialogService Пользователи @code { IEnumerable usersWithRoles; bool isLoading; protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); if (firstRender) { isLoading = true; StateHasChanged(); var state = await AuthenticationStateProvider.GetAuthenticationStateAsync(); if (state.User.Identity?.IsAuthenticated ?? false) { usersWithRoles = await UsersService.GetUsersWithRole(); } isLoading = false; StateHasChanged(); } } async Task AddUser() { var success = await DialogService.OpenAsync( "Создание пользователя", null, new DialogOptions() { Width = "420px", ShowClose = false, CloseDialogOnEsc = false, CloseDialogOnOverlayClick = false }); if (success) { await UpdateGrid(); } } async Task EditUser(AppUserWithRole userWithRole) { // TODO: Implement method } async Task DeleteUser(AppUserWithRole userWithRole) { // TODO: Implement method } async Task UpdateGrid() { isLoading = true; usersWithRoles = await UsersService.GetUsersWithRole(); isLoading = false; } }