Added client side repos
This commit is contained in:
15
src/Portfolio.Web/Services/TimelineRepository.cs
Normal file
15
src/Portfolio.Web/Services/TimelineRepository.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Portfolio.Shared.Models;
|
||||
using Portfolio.Shared.Services;
|
||||
|
||||
namespace Portfolio.Web.Services;
|
||||
|
||||
internal sealed class TimelineRepository(IHttpClientFactory factory) : ITimelineRepository {
|
||||
public async Task<IEnumerable<TimelineEntry>> GetTimeline(TimelineEntryType type, CancellationToken ct) {
|
||||
var client = factory.CreateClient("api");
|
||||
var result = await client.GetAsync($"api/timeline/{type}", ct);
|
||||
if (!result.IsSuccessStatusCode) return [];
|
||||
|
||||
var data = await result.Content.ReadFromJsonAsync<IEnumerable<TimelineEntry>>(ct);
|
||||
return data ?? [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user