This commit is contained in:
37
server/util/ServerGlobalBizSettings.cs
Normal file
37
server/util/ServerGlobalBizSettings.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Linq;
|
||||
using Sockeye.Models;
|
||||
|
||||
namespace Sockeye.Util
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Contains static mirror copy in memory of global settings values that are set from DB during boot
|
||||
/// and accessible to Biz admin user (equivalent of v7's global object)
|
||||
/// used by many areas of the biz logic and processing too often to fetch on every request
|
||||
/// set at boot and on any update to the db global biz settings record
|
||||
/// </summary>
|
||||
internal static class ServerGlobalBizSettings
|
||||
{
|
||||
internal static GlobalBizSettings Cache { get; set; }
|
||||
/// <summary>
|
||||
/// Populate and / or create the settings
|
||||
/// </summary>
|
||||
internal static void Initialize(GlobalBizSettings global, AyContext ct)
|
||||
{
|
||||
if (global == null)
|
||||
{
|
||||
|
||||
|
||||
//fetch or create as not provided (meaning this was called from Startup.cs)
|
||||
global = ct.GlobalBizSettings.FirstOrDefault(z => z.Id == 1);
|
||||
if (global == null)
|
||||
{
|
||||
global = new GlobalBizSettings();
|
||||
ct.GlobalBizSettings.Add(global);
|
||||
ct.SaveChanges();
|
||||
}
|
||||
}
|
||||
Cache = global;
|
||||
}
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user