From c92d13797f68d4abcddfd54bcc7147b369ef3572 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Sun, 23 Jul 2023 22:58:25 -0700 Subject: [PATCH] minor adjustments --- .../Repositories/DiscordWebhooksTable.cs | 11 +++++++++++ .../Repositories/UserSourceSubscriptionTable.cs | 3 ++- .../Interfaces/IDiscordWebHooksRepository.cs | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Newsbot.Collector.Database/Repositories/DiscordWebhooksTable.cs b/Newsbot.Collector.Database/Repositories/DiscordWebhooksTable.cs index c667d23..74b53aa 100644 --- a/Newsbot.Collector.Database/Repositories/DiscordWebhooksTable.cs +++ b/Newsbot.Collector.Database/Repositories/DiscordWebhooksTable.cs @@ -1,5 +1,6 @@ using System.Data; using Dapper; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Newsbot.Collector.Domain.Interfaces; using Newsbot.Collector.Domain.Entities; @@ -60,6 +61,16 @@ public class DiscordWebhooksTable : IDiscordWebHooksRepository return res; } + public List ListByUserId(string userId, int page) + { + var query = _context.DiscordWebhooks + .Where(p => p.UserId != null && p.UserId.Equals(userId)) + .Skip(page * 25) + .Take(25) + .ToList(); + return query; + } + public List ListByServer(string server, int limit = 25) { //using var context = new DatabaseContext(_connectionString); diff --git a/Newsbot.Collector.Database/Repositories/UserSourceSubscriptionTable.cs b/Newsbot.Collector.Database/Repositories/UserSourceSubscriptionTable.cs index fcfb314..2feb020 100644 --- a/Newsbot.Collector.Database/Repositories/UserSourceSubscriptionTable.cs +++ b/Newsbot.Collector.Database/Repositories/UserSourceSubscriptionTable.cs @@ -19,7 +19,8 @@ public class UserSourceSubscriptionTable : IUserSourceSubscription public List ListUserSubscriptions(Guid userId) { - var results =_context.UserSourceSubscription.Where(i => i.UserId.Equals(userId)).ToList(); + var results =_context.UserSourceSubscription + .Where(i => i.UserId != null && i.UserId.Equals(userId)).ToList(); return results; } } diff --git a/Newsbot.Collector.Domain/Interfaces/IDiscordWebHooksRepository.cs b/Newsbot.Collector.Domain/Interfaces/IDiscordWebHooksRepository.cs index 2192371..6d32c9d 100644 --- a/Newsbot.Collector.Domain/Interfaces/IDiscordWebHooksRepository.cs +++ b/Newsbot.Collector.Domain/Interfaces/IDiscordWebHooksRepository.cs @@ -10,6 +10,7 @@ public interface IDiscordWebHooksRepository DiscordWebhookEntity GetByUrl(string url); List List(int page, int count = 25); + List ListByUserId(string userId, int page); List ListByServer(string server, int limit); List ListByServerAndChannel(string server, string channel, int limit);