2023-11-11 22:04:11 +01:00
|
|
|
|
namespace TaikoWebUI.Pages.Dialogs;
|
|
|
|
|
|
|
|
|
|
public partial class UserDeleteConfirmDialog
|
|
|
|
|
{
|
2024-03-09 00:42:56 +01:00
|
|
|
|
|
2023-11-11 22:04:11 +01:00
|
|
|
|
[CascadingParameter]
|
|
|
|
|
MudDialogInstance MudDialog { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public User User { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
private void Cancel() => MudDialog.Cancel();
|
2024-03-09 00:42:56 +01:00
|
|
|
|
|
2023-11-11 22:04:11 +01:00
|
|
|
|
private async Task DeleteUser()
|
|
|
|
|
{
|
2023-11-12 18:56:57 +01:00
|
|
|
|
var responseMessage = await Client.DeleteAsync($"api/Users/{User.Baid}");
|
2023-11-11 22:04:11 +01:00
|
|
|
|
|
2023-11-12 18:56:57 +01:00
|
|
|
|
if (!responseMessage.IsSuccessStatusCode)
|
2023-11-12 18:41:36 +01:00
|
|
|
|
{
|
|
|
|
|
Snackbar.Add("Something went wrong when deleting user!", Severity.Error);
|
|
|
|
|
MudDialog.Close(DialogResult.Ok(false));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-09 00:42:56 +01:00
|
|
|
|
|
2023-11-11 22:04:11 +01:00
|
|
|
|
Snackbar.Add("Delete success!", Severity.Success);
|
|
|
|
|
MudDialog.Close(DialogResult.Ok(true));
|
|
|
|
|
}
|
|
|
|
|
}
|