Refactored CatalogApiClient, DashboardApiClient, LayoutApiClient, and MassDataApiClient to use C# primary constructor syntax for injecting HttpClient. Removed private _httpClient fields and updated all usages to reference the constructor parameter directly. This change simplifies the code and modernizes dependency injection without altering any API logic.
15 lines
450 B
C#
15 lines
450 B
C#
using DbFirst.Contracts.Dashboards;
|
|
|
|
namespace DbFirst.BlazorWebApp.Services;
|
|
|
|
public class DashboardApiClient(HttpClient httpClient) : IDashboardApiClient
|
|
{
|
|
private const string Endpoint = "api/dashboard/dashboards";
|
|
|
|
public async Task<List<DashboardInfoDto>> GetAllAsync(CancellationToken ct = default)
|
|
{
|
|
var result = await httpClient.GetFromJsonAsync<List<DashboardInfoDto>>(Endpoint, ct);
|
|
return result ?? [];
|
|
}
|
|
}
|