1
0
mirror of synced 2024-12-11 22:16:00 +01:00
GC-local-server-rewrite/WebUI/Pages/Cards.razor.cs

51 lines
1.4 KiB
C#
Raw Normal View History

2023-02-16 17:38:01 +01:00
using System.Net.Http.Json;
using Microsoft.AspNetCore.Components;
2023-02-17 18:29:20 +01:00
using MudBlazor;
using Shared.Dto.Api;
using Shared.Models;
2023-02-16 17:38:01 +01:00
namespace WebUI.Pages;
public partial class Cards
{
[Inject]
2023-02-17 18:29:20 +01:00
public required HttpClient Client { get; set; }
[Inject]
public required IDialogService DialogService { get; set; }
2023-02-16 17:38:01 +01:00
private List<ClientCardDto>? CardDtos { get; set; }
private string ErrorMessage { get; set; } = string.Empty;
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
var result = await Client.GetFromJsonAsync<ServiceResult<List<ClientCardDto>>>("api/Profiles");
if (result is null)
{
ErrorMessage = "Parse result failed";
return;
}
if (!result.Succeeded)
{
ErrorMessage = result.Error!.Message;
return;
}
CardDtos = result.Data;
}
2023-02-17 18:29:20 +01:00
private async Task OnEditPlayerNameClicked(ClientCardDto card)
{
var options = new DialogOptions
{
CloseOnEscapeKey = false,
DisableBackdropClick = true,
FullWidth = true
};
var parameters = new DialogParameters { { "Data", card } };
var dialog = await DialogService.ShowAsync<ChangePlayerNameDialog>("Favorite", parameters, options);
var result = await dialog.Result;
}
2023-02-16 17:38:01 +01:00
}