Renamed DeepL mode setting

This commit is contained in:
tsommer committed 2022-07-30 16:09:58 +02:00
1 parent 87c12de066
commit b74367aa6f
3 files changed
+13 -13

No files matched your search

+5 -5
View File
@@ -9,7 +9,7 @@ public static class AppSettings
{
#region DeepL Mode
public static async Task SetDeepLMode(SettingDeepL mode)
public static async Task SetDeepLMode(SettingDeepLMode mode)
{
// Convert the enum to its int value:
var intValue = (int)mode;
@@ -38,26 +38,26 @@ public static class AppSettings
}
}
public static async Task<SettingDeepL> GetDeepLMode()
public static async Task<SettingDeepLMode> GetDeepLMode()
{
// Get the database:
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
// Check, if the setting is already set:
if (await db.Settings.FirstOrDefaultAsync(n => n.Code == SettingNames.DEEPL_MODE) is { } existingSetting)
return (SettingDeepL) existingSetting.IntegerValue;
return (SettingDeepLMode) existingSetting.IntegerValue;
// Does not exist, so create it:
var setting = new Setting
{
Code = SettingNames.DEEPL_MODE,
IntegerValue = (int)SettingDeepL.DISABLED,
IntegerValue = (int)SettingDeepLMode.DISABLED,
};
await db.Settings.AddAsync(setting);
await db.SaveChangesAsync();
return (SettingDeepL) setting.IntegerValue;
return (SettingDeepLMode) setting.IntegerValue;
}
#endregion