using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CodeHollow.FeedReader;
using SharpRss.Models;
using ToolQit.Extensions;
namespace SharpRss.Services
{
///
/// Managing RSS feeds and categories.
///
public class RssService
{
public RssService()
{
//SetupTestCategoriesAndFeedsAsync();
}
private readonly DatabaseService _dbService = new DatabaseService();
private async void SetupTestCategoriesAndFeedsAsync()
{
await _dbService.AddCategoriesAsync(new HashSet()
{
new CategoryModel() { Name = "All" },
new CategoryModel() { Name = "RSS" },
new CategoryModel() { Name = "Tech" },
new CategoryModel() { Name = "News" }
});
await _dbService.AddFeedsAsync(new HashSet()
{
new FeedModel("http://fedoramagazine.org/feed/"),
new FeedModel("https://www.nasa.gov/rss/dyn/breaking_news.rss"),
new FeedModel("https://journals.plos.org/plosone/feed/atom"),
new FeedModel("https://itsfoss.com/feed")
});
}
public async Task GetFeedAsync(string rssUrl)
{
return await FeedCache.GetFeed(rssUrl);
}
public async Task> GetAllUnsortedAsync()
{
HashSet