All API client interfaces and implementations now accept an optional CancellationToken parameter for each method. This enables consumers to cancel HTTP requests, improving responsiveness and resource management. No changes were made to core logic or return types; only method signatures and HttpClient calls were updated to support cancellation.
22 lines
626 B
C#
22 lines
626 B
C#
using System.Net.Http.Json;
|
|
using DbFirst.BlazorWebApp.Models;
|
|
|
|
namespace DbFirst.BlazorWebApp.Services;
|
|
|
|
public class DashboardApiClient : IDashboardApiClient
|
|
{
|
|
private readonly HttpClient _httpClient;
|
|
private const string Endpoint = "api/dashboard/dashboards";
|
|
|
|
public DashboardApiClient(HttpClient httpClient)
|
|
{
|
|
_httpClient = httpClient;
|
|
}
|
|
|
|
public async Task<List<DashboardInfoDto>> GetAllAsync(CancellationToken ct = default)
|
|
{
|
|
var result = await _httpClient.GetFromJsonAsync<List<DashboardInfoDto>>(Endpoint, ct);
|
|
return result ?? new List<DashboardInfoDto>();
|
|
}
|
|
}
|