refactor: add SqlKata for SQL generation, move connection handling into ModelRepository

This commit is contained in:
spiral
2021-09-29 21:51:38 -04:00
parent 6251d29abb
commit 92e45a07ff
60 changed files with 806 additions and 640 deletions

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@@ -26,13 +27,10 @@ namespace PluralKit.Bot
{
ctx.CheckSystem();
var members = await _db.Execute(c =>
{
if (ctx.MatchFlag("all", "a"))
return _repo.GetSystemMembers(c, ctx.System.Id);
return _repo.GetSystemMembers(c, ctx.System.Id)
.Where(m => m.MemberVisibility == PrivacyLevel.Public);
}).ToListAsync();
var members = await _repo.GetSystemMembers(ctx.System.Id).ToListAsync();
if (!ctx.MatchFlag("all", "a"))
members = members.Where(m => m.MemberVisibility == PrivacyLevel.Public).ToList();
if (members == null || !members.Any())
throw new PKError("Your system has no members! Please create at least one member before using this command.");