From 338edf8d4e213b0020596b9e80c3a340d378972e Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Sun, 6 Aug 2023 13:34:54 -0700 Subject: [PATCH] Added TotalByTypeAsync to see if we need to pull multiple pages --- .../Repositories/SourcesTable.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Newsbot.Collector.Database/Repositories/SourcesTable.cs b/Newsbot.Collector.Database/Repositories/SourcesTable.cs index 8340de0..829d35e 100644 --- a/Newsbot.Collector.Database/Repositories/SourcesTable.cs +++ b/Newsbot.Collector.Database/Repositories/SourcesTable.cs @@ -1,17 +1,13 @@ -using System.Data; -using Dapper; -using Microsoft.Extensions.Configuration; +using Microsoft.EntityFrameworkCore; using Newsbot.Collector.Domain.Entities; using Newsbot.Collector.Domain.Interfaces; -using Newsbot.Collector.Domain.Models; -using Npgsql; namespace Newsbot.Collector.Database.Repositories; public class SourcesTable : ISourcesRepository { //private readonly string _connectionString; - private DatabaseContext _context; + private readonly DatabaseContext _context; public SourcesTable(string connectionString) { @@ -114,6 +110,14 @@ public class SourcesTable : ISourcesRepository return res; } + public async Task TotalByTypeAsync(string type) + { + var res = await _context.Sources + .Where(f => f.Type == type ) + .CountAsync(); + return res; + } + public int Disable(Guid id) { //using var context = new DatabaseContext(_connectionString);