All checks were successful
Restart Docker Container on Production / build (pull_request) Successful in 3m9s
40 lines
972 B
C#
40 lines
972 B
C#
|
|
using System.Net.Http.Json;
|
|
using RBLFeederCommon.Models.RssFeed;
|
|
|
|
using RBLNews.Shared.Services.Contracts;
|
|
|
|
namespace RBLNews.Shared.Services
|
|
{
|
|
public interface IFeedDataService
|
|
{
|
|
public RssVM Feeds { get; }
|
|
|
|
public Action DataChanged { get; set; }
|
|
|
|
Task LoadFeeds();
|
|
}
|
|
|
|
public class FeedDataService : IFeedDataService
|
|
{
|
|
private readonly IConfigService _configService;
|
|
|
|
private static readonly HttpClient httpClient = new();
|
|
|
|
public RssVM Feeds { get; private set; }
|
|
|
|
public Action DataChanged { get; set; }
|
|
|
|
public FeedDataService(IConfigService configService)
|
|
{
|
|
this._configService = configService;
|
|
}
|
|
|
|
public async Task LoadFeeds()
|
|
{
|
|
Feeds = await httpClient.GetFromJsonAsync<RssVM>($"{this._configService.AppSettings.BackendApiUrl}/feeds") ?? new RssVM();
|
|
DataChanged.Invoke();
|
|
}
|
|
}
|
|
}
|