using System;
using System.Linq;
using AyaNova.Models;
namespace AyaNova.Util
{
///
/// Contains static mirror copy in memory of Operations related settings stored in db
/// that are accessed frequently by server
///
internal static class ServerGlobalOpsSettingsCache
{
internal static GlobalOpsBackupSettings Backup { get; set; }
// internal static DateTime LastBackup { get; set; }
///
/// Populate and / or create the settings
///
internal static void Initialize(AyContext ct = null)
{
//fetch or create as not provided (meaning this was called from Startup.cs)
Backup = ct.GlobalOpsBackupSettings.FirstOrDefault(z => z.Id == 1);
if (Backup == null)
{
Backup = new GlobalOpsBackupSettings();
ct.GlobalOpsBackupSettings.Add(Backup);
ct.SaveChanges();
}
Backup.LastBackup=FileUtil.MostRecentBackupFileDate();
}
}//eoc
}//eons