Implemented the culture delete function

This commit is contained in:
tsommer committed 2022-08-02 20:43:58 +02:00
1 parent fee963f8bd
commit 0c53c97a48
7 files changed
+94

No files matched your search

+23
View File
@@ -385,6 +385,29 @@ public static class AppSettings
#endregion
#region Delete a culture
public static async Task DeleteCulture(int index)
{
// 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.StartsWith(SettingNames.CULTURE) && n.IntegerValue == index) is {} existingSetting)
{
db.Settings.Remove(existingSetting);
await db.SaveChangesAsync();
}
// Update the list of cultures indices:
CACHE_CULTURES_INDICES.Remove(index);
// Update the cache:
CACHE_CULTURES.Remove(index);
}
#endregion
#region Get a list of cultures
public readonly record struct CultureInfo(string Code, int Index);