2024-05-16 23:32:46 +01:00
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
using Blazored.LocalStorage;
|
|
|
|
|
|
|
|
|
|
namespace TaikoWebUI.Pages.Dialogs;
|
2023-11-11 21:04:11 +00:00
|
|
|
|
|
|
|
|
|
public partial class UserDeleteConfirmDialog
|
|
|
|
|
{
|
2024-05-16 23:32:46 +01:00
|
|
|
|
[CascadingParameter] private MudDialogInstance MudDialog { get; set; } = null!;
|
2023-11-11 21:04:11 +00:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public User User { get; set; } = new();
|
|
|
|
|
|
2024-05-16 23:32:46 +01:00
|
|
|
|
[Inject]
|
|
|
|
|
public ILocalStorageService LocalStorage { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
public AuthService AuthService { get; set; } = null!;
|
|
|
|
|
|
2023-11-11 21:04:11 +00:00
|
|
|
|
private void Cancel() => MudDialog.Cancel();
|
2024-03-08 18:42:56 -05:00
|
|
|
|
|
2023-11-11 21:04:11 +00:00
|
|
|
|
private async Task DeleteUser()
|
|
|
|
|
{
|
2023-11-12 17:56:57 +00:00
|
|
|
|
var responseMessage = await Client.DeleteAsync($"api/Users/{User.Baid}");
|
2023-11-11 21:04:11 +00:00
|
|
|
|
|
2023-11-12 17:56:57 +00:00
|
|
|
|
if (!responseMessage.IsSuccessStatusCode)
|
2023-11-12 17:41:36 +00:00
|
|
|
|
{
|
2024-06-05 02:07:33 +01:00
|
|
|
|
Snackbar.Add(Localizer["Unknown Error"], Severity.Error);
|
2023-11-12 17:41:36 +00:00
|
|
|
|
MudDialog.Close(DialogResult.Ok(false));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-08 18:42:56 -05:00
|
|
|
|
|
2024-06-05 02:07:33 +01:00
|
|
|
|
Snackbar.Add(Localizer["Delete User Success"], Severity.Success);
|
2023-11-11 21:04:11 +00:00
|
|
|
|
MudDialog.Close(DialogResult.Ok(true));
|
|
|
|
|
}
|
|
|
|
|
}
|