Split out backup settings from general ops settings

This commit is contained in:
2020-05-21 21:19:34 +00:00
parent 8b778be04b
commit f239e1605e
9 changed files with 87 additions and 77 deletions

View 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