1
0
mirror of synced 2025-03-02 16:23:27 +01:00

34 lines
859 B
C#
Raw Normal View History

2023-02-17 00:38:01 +08:00
using System.Net.Http.Json;
using Application.Common.Models;
using Application.Dto.Api;
using Microsoft.AspNetCore.Components;
namespace WebUI.Pages;
public partial class Cards
{
[Inject]
public HttpClient Client { get; set; } = null!;
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;
}
}