1
0
mirror of synced 2024-12-04 19:07:58 +01:00
TaikoLocalServer/TaikoWebUI/Pages/Cards.razor.cs

91 lines
2.6 KiB
C#
Raw Normal View History

2022-09-11 18:33:58 +02:00
using TaikoWebUI.Pages.Dialogs;
namespace TaikoWebUI.Pages;
public partial class Cards
{
2023-10-16 11:38:27 +02:00
private string cardNum = "";
private MudForm loginForm = default!;
private string password = "";
2022-09-11 18:33:58 +02:00
private DashboardResponse? response;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
response = await Client.GetFromJsonAsync<DashboardResponse>("api/Dashboard");
}
private async Task DeleteCard(User user)
{
var parameters = new DialogParameters
{
["user"] = user
};
var dialog = DialogService.Show<CardDeleteConfirmDialog>("Delete Card", parameters);
var result = await dialog.Result;
if (result.Canceled) return;
2023-09-09 14:58:20 +02:00
response = await Client.GetFromJsonAsync<DashboardResponse>("api/Dashboard");
}
2023-10-16 11:38:27 +02:00
private async Task OnLogin()
{
if (response != null)
2022-09-11 18:33:58 +02:00
{
2023-10-16 11:38:27 +02:00
var result = LoginService.Login(cardNum, password, response);
switch (result)
{
case 0:
await DialogService.ShowMessageBox(
"Error",
"Only admin can log in.",
"Ok");
await loginForm.ResetAsync();
2023-10-16 11:38:27 +02:00
break;
case 1:
NavigationManager.NavigateTo("/Cards");
break;
case 2:
await DialogService.ShowMessageBox(
"Error",
"Wrong password!",
"Ok");
break;
case 3:
await DialogService.ShowMessageBox(
"Error",
(MarkupString)
"Card number not found.<br />Please play one game with this card number to register it.",
"Ok");
break;
case 4:
await DialogService.ShowMessageBox(
"Error",
(MarkupString)
"Card number not registered.<br />Please use register button to create a password first.",
"Ok");
break;
}
2022-09-11 18:33:58 +02:00
}
2023-10-16 11:38:27 +02:00
}
2022-09-11 18:33:58 +02:00
2023-10-16 11:38:27 +02:00
private void OnLogout()
{
LoginService.Logout();
NavigationManager.NavigateTo("/Cards");
2022-09-11 18:33:58 +02:00
}
2023-10-16 11:38:27 +02:00
2023-10-01 14:09:04 +02:00
private Task ShowQrCode(User user)
{
var parameters = new DialogParameters
{
["user"] = user
};
DialogService.Show<UserQrCodeDialog>("QR Code", parameters);
2022-09-11 18:33:58 +02:00
2023-10-01 14:09:04 +02:00
return Task.CompletedTask;
}
2022-09-11 18:33:58 +02:00
}