@ -1,5 +1,4 @@
using System.ComponentModel ;
using AdminPanel.Models ;
using AdminPanel.Models ;
using AdminPanel.Services ;
using Microsoft.AspNetCore.Components ;
using Microsoft.AspNetCore.Components.Web ;
@ -12,6 +11,9 @@ namespace AdminPanel.Pages
[Inject] public ISnackbar Snackbar { get ; private init ; }
[Inject] public IUsersService Service { get ; private init ; }
private MudDataGrid < User > Grid { get ; set ; }
private HashSet < User > SelectedItems { get ; set ; } = new ( ) ;
private string? FormAccountName { get ; set ; }
@ -33,7 +35,7 @@ namespace AdminPanel.Pages
}
private async void OnAccount Edi ted( User user )
private async void OnAccount Upda ted( User user )
{
Console . WriteLine ( user . IsAdmin ) ;
try
@ -42,7 +44,8 @@ namespace AdminPanel.Pages
}
catch ( Exception )
{
Snackbar . Add ( "Server responded with errors, your given input may be incorrect.\nIf you entered a new email, verify that the email is not used by another member." ) ;
Snackbar . Add (
"Server responded with errors, your given input may be incorrect.\nIf you entered a new email, verify that the email is not used by another member." ) ;
}
}
@ -55,7 +58,7 @@ namespace AdminPanel.Pages
{
await Service . AddUser ( FormAccountName ! , FormAccountEmail ! , FormAccountPassword ! ,
FormAccountIsAdmin ) ;
StateHasChanged ( ) ;
await Grid . ReloadServerData ( ) ;
}
catch ( Exception )
{
@ -70,11 +73,17 @@ namespace AdminPanel.Pages
try
{
await Service . RemoveUsers ( items ) ;
await Grid . ReloadServerData ( ) ;
}
catch ( Exception )
{
Snackbar . Add ( "Server responded with errors" ) ;
}
}
private Func < string , string? > VerifyLength ( uint min , uint max )
{
return s = > ( s . Length > = min & & s . Length < = max ) ? null : $"length is incorrect (must be between {min} and {max})" ;
}
}
}