features/api-cleanup #15

Merged
jtom38 merged 13 commits from features/api-cleanup into main 2023-07-29 09:47:30 -07:00
3 changed files with 14 additions and 1 deletions
Showing only changes of commit c92d13797f - Show all commits

View File

@ -1,5 +1,6 @@
using System.Data; using System.Data;
using Dapper; using Dapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Newsbot.Collector.Domain.Interfaces; using Newsbot.Collector.Domain.Interfaces;
using Newsbot.Collector.Domain.Entities; using Newsbot.Collector.Domain.Entities;
@ -60,6 +61,16 @@ public class DiscordWebhooksTable : IDiscordWebHooksRepository
return res; return res;
} }
public List<DiscordWebhookEntity> 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<DiscordWebhookEntity> ListByServer(string server, int limit = 25) public List<DiscordWebhookEntity> ListByServer(string server, int limit = 25)
{ {
//using var context = new DatabaseContext(_connectionString); //using var context = new DatabaseContext(_connectionString);

View File

@ -19,7 +19,8 @@ public class UserSourceSubscriptionTable : IUserSourceSubscription
public List<UserSourceSubscriptionEntity> ListUserSubscriptions(Guid userId) public List<UserSourceSubscriptionEntity> 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; return results;
} }
} }

View File

@ -10,6 +10,7 @@ public interface IDiscordWebHooksRepository
DiscordWebhookEntity GetByUrl(string url); DiscordWebhookEntity GetByUrl(string url);
List<DiscordWebhookEntity> List(int page, int count = 25); List<DiscordWebhookEntity> List(int page, int count = 25);
List<DiscordWebhookEntity> ListByUserId(string userId, int page);
List<DiscordWebhookEntity> ListByServer(string server, int limit); List<DiscordWebhookEntity> ListByServer(string server, int limit);
List<DiscordWebhookEntity> ListByServerAndChannel(string server, string channel, int limit); List<DiscordWebhookEntity> ListByServerAndChannel(string server, string channel, int limit);