Resolve "Component: Settings" #69

Merged
thorsten merged 32 commits from 13-component-settings into main 2022-08-05 19:35:32 +00:00
Showing only changes of commit 9419642525 - Show all commits
+14
View File
@@ -213,8 +213,14 @@ public static class AppSettings
#region Number of cultures
private static int CACHE_NUMBER_OF_CULTURES = -1;
public static async Task<int> GetNumberCultures()
{
// When possible, use the cache:
if (CACHE_NUMBER_OF_CULTURES > -1)
return CACHE_NUMBER_OF_CULTURES;
// Get the database:
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
@@ -223,8 +229,12 @@ public static class AppSettings
// We have at least one default culture:
if(count == 0)
{
CACHE_NUMBER_OF_CULTURES = 1;
return 1;
}
CACHE_NUMBER_OF_CULTURES = count;
return count;
}
@@ -291,6 +301,10 @@ public static class AppSettings
await db.Settings.AddAsync(setting);
await db.SaveChangesAsync();
// Update the number of cultures cache:
if(CACHE_NUMBER_OF_CULTURES > -1)
CACHE_NUMBER_OF_CULTURES++;
}
}