Split out backup settings from general ops settings
This commit is contained in:
36
server/AyaNova/util/ServerGlobalOpsSettingsCache.cs
Normal file
36
server/AyaNova/util/ServerGlobalOpsSettingsCache.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AyaNova.Models;
|
||||
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Contains static mirror copy in memory of Operations related settings stored in db
|
||||
/// that are accessed frequently by server
|
||||
/// </summary>
|
||||
internal static class ServerGlobalOpsSettingsCache
|
||||
{
|
||||
|
||||
internal static GlobalOpsBackupSettings Backup { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Populate and / or create the settings
|
||||
/// </summary>
|
||||
internal static void Initialize(AyContext ct = null)
|
||||
{
|
||||
//fetch or create as not provided (meaning this was called from Startup.cs)
|
||||
Backup = ct.GlobalOpsSettings.FirstOrDefault(z => z.Id == 1);
|
||||
if (Backup == null)
|
||||
{
|
||||
Backup = new GlobalOpsBackupSettings();
|
||||
ct.GlobalOpsSettings.Add(Backup);
|
||||
ct.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user