20 lines
662 B
C#
20 lines
662 B
C#
using Portfolio.Shared.Models;
|
|
using Portfolio.Shared.Services;
|
|
|
|
namespace Portfolio.Web.Services;
|
|
|
|
internal sealed class AboutRepository(IHttpClientFactory factory) : IAboutRepository {
|
|
private About DefaultValue => new() {
|
|
AboutMe = string.Empty,
|
|
Future = string.Empty
|
|
};
|
|
|
|
public async Task<About> GetAbout(CancellationToken ct) {
|
|
var client = factory.CreateClient("api");
|
|
var response = await client.GetAsync("api/about", ct);
|
|
if (!response.IsSuccessStatusCode) return DefaultValue;
|
|
|
|
var data = await response.Content.ReadFromJsonAsync<About>(ct);
|
|
return data ?? DefaultValue;
|
|
}
|
|
} |