Removed sar repository

This commit is contained in:
Kwoth
2021-06-18 08:49:06 +02:00
parent ae59bac118
commit afaeab40a3
6 changed files with 34 additions and 52 deletions

View File

@@ -11,7 +11,6 @@ namespace NadekoBot.Core.Services.Database
IQuoteRepository Quotes { get; }
IGuildConfigRepository GuildConfigs { get; }
IReminderRepository Reminders { get; }
ISelfAssignedRolesRepository SelfAssignedRoles { get; }
ICustomReactionRepository CustomReactions { get; }
IMusicPlaylistRepository MusicPlaylists { get; }
IWaifuRepository Waifus { get; }

View File

@@ -1,11 +0,0 @@
using NadekoBot.Core.Services.Database.Models;
using System.Collections.Generic;
namespace NadekoBot.Core.Services.Database.Repositories
{
public interface ISelfAssignedRolesRepository : IRepository<SelfAssignedRole>
{
bool DeleteByGuildAndRoleId(ulong guildId, ulong roleId);
IEnumerable<SelfAssignedRole> GetFromGuild(ulong guildId);
}
}

View File

@@ -0,0 +1,26 @@
using NadekoBot.Core.Services.Database.Models;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace NadekoBot.Modules.Administration.Common
{
public static class SelfAssignableRolesExtensions
{
public static bool DeleteByGuildAndRoleId(this DbSet<SelfAssignedRole> roles, ulong guildId, ulong roleId)
{
var role = roles.FirstOrDefault(s => s.GuildId == guildId && s.RoleId == roleId);
if (role == null)
return false;
roles.Remove(role);
return true;
}
public static IEnumerable<SelfAssignedRole> GetFromGuild(this DbSet<SelfAssignedRole> roles, ulong guildId)
=> roles.AsQueryable()
.Where(s => s.GuildId == guildId)
.ToArray();
}
}

View File

@@ -1,30 +0,0 @@
using NadekoBot.Core.Services.Database.Models;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace NadekoBot.Core.Services.Database.Repositories.Impl
{
public class SelfAssignedRolesRepository : Repository<SelfAssignedRole>, ISelfAssignedRolesRepository
{
public SelfAssignedRolesRepository(DbContext context) : base(context)
{
}
public bool DeleteByGuildAndRoleId(ulong guildId, ulong roleId)
{
var role = _set.FirstOrDefault(s => s.GuildId == guildId && s.RoleId == roleId);
if (role == null)
return false;
_set.Remove(role);
return true;
}
public IEnumerable<SelfAssignedRole> GetFromGuild(ulong guildId)
=> _set.AsQueryable()
.Where(s => s.GuildId == guildId)
.ToArray();
}
}

View File

@@ -18,9 +18,6 @@ namespace NadekoBot.Core.Services.Database
private IReminderRepository _reminders;
public IReminderRepository Reminders => _reminders ?? (_reminders = new ReminderRepository(_context));
private ISelfAssignedRolesRepository _selfAssignedRoles;
public ISelfAssignedRolesRepository SelfAssignedRoles => _selfAssignedRoles ?? (_selfAssignedRoles = new SelfAssignedRolesRepository(_context));
private IMusicPlaylistRepository _musicPlaylists;
public IMusicPlaylistRepository MusicPlaylists => _musicPlaylists ?? (_musicPlaylists = new MusicPlaylistRepository(_context));