Add delete configuration flag

This commit is contained in:
Daniel_I_Am 2020-08-13 22:37:45 +02:00
parent dc986457e5
commit 61ef1e0ed9
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84

View File

@ -25,6 +25,18 @@ namespace ChaosBot.Repositories
}
}
public static void DeleteValue(string key, ulong guildId)
{
using (ChaosbotContext dbContext = new ChaosbotContext())
{
Configuration config = dbContext.Configuration
.SingleOrDefault(c => c.DiscordGuildId == guildId && c.Key == key);
if (config == null) return;
dbContext.Remove(config);
dbContext.SaveChanges();
}
}
private static T GetValueFromAppSettings<T>(string key, ulong guildId, T defaultValue)
{
return Program.AppSettingsHandler.GetValue($"Servers:{guildId}:{key}", Program.AppSettingsHandler.GetValue(key, defaultValue));