1
0
mirror of synced 2024-12-20 02:15:56 +01:00
TaikoLocalServer/TaikoWebUI/Pages/Dialogs/UserDeleteConfirmDialog.razor.cs

35 lines
971 B
C#
Raw Normal View History

2024-05-17 00:32:46 +02:00
using System.Net.Http.Headers;
using Blazored.LocalStorage;
namespace TaikoWebUI.Pages.Dialogs;
public partial class UserDeleteConfirmDialog
{
2024-05-17 00:32:46 +02:00
[CascadingParameter] private MudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public User User { get; set; } = new();
2024-05-17 00:32:46 +02:00
[Inject]
public ILocalStorageService LocalStorage { get; set; } = null!;
[Inject]
public AuthService AuthService { get; set; } = null!;
private void Cancel() => MudDialog.Cancel();
2024-03-09 00:42:56 +01:00
private async Task DeleteUser()
{
var responseMessage = await Client.DeleteAsync($"api/Users/{User.Baid}");
if (!responseMessage.IsSuccessStatusCode)
{
Snackbar.Add("Something went wrong when deleting user!", Severity.Error);
MudDialog.Close(DialogResult.Ok(false));
return;
}
2024-03-09 00:42:56 +01:00
Snackbar.Add("Delete success!", Severity.Success);
MudDialog.Close(DialogResult.Ok(true));
}
}