1
0
mirror of synced 2024-12-25 04:44:52 +01:00
TaikoLocalServer/TaikoWebUI/Pages/Dialogs/UserDeleteConfirmDialog.razor.cs
2024-06-05 02:07:33 +01:00

35 lines
970 B
C#

using System.Net.Http.Headers;
using Blazored.LocalStorage;
namespace TaikoWebUI.Pages.Dialogs;
public partial class UserDeleteConfirmDialog
{
[CascadingParameter] private MudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public User User { get; set; } = new();
[Inject]
public ILocalStorageService LocalStorage { get; set; } = null!;
[Inject]
public AuthService AuthService { get; set; } = null!;
private void Cancel() => MudDialog.Cancel();
private async Task DeleteUser()
{
var responseMessage = await Client.DeleteAsync($"api/Users/{User.Baid}");
if (!responseMessage.IsSuccessStatusCode)
{
Snackbar.Add(Localizer["Unknown Error"], Severity.Error);
MudDialog.Close(DialogResult.Ok(false));
return;
}
Snackbar.Add(Localizer["Delete User Success"], Severity.Success);
MudDialog.Close(DialogResult.Ok(true));
}
}