This commit is contained in:
2025-10-27 17:39:18 -04:00
commit 31f723bea4
1579 changed files with 642409 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
using System.Net;
using System.Net.Http.Json;
using Prefab.Web.Client.Models.Home;
using Prefab.Web.Client.Models.Shared;
namespace Prefab.Web.Client.Services;
public interface IHomePageService
{
Task<Result<HomePageModel>> Get(CancellationToken cancellationToken);
}
public sealed class HomePageService(HttpClient httpClient) : IHomePageService
{
public async Task<Result<HomePageModel>> Get(CancellationToken cancellationToken)
{
using var response = await httpClient.GetAsync("bff/home", cancellationToken);
var result = await response.Content.ReadFromJsonAsync<Result<HomePageModel>>(cancellationToken: cancellationToken);
if (result is not null)
{
return result;
}
var status = (HttpStatusCode)response.StatusCode;
var exception = new InvalidOperationException($"Response {(int)status} did not contain a valid payload.");
var problem = ResultProblem.Unexpected("Failed to retrieve home page content.", exception, status);
return Result<HomePageModel>.Failure(problem);
}
}