More UI updates

This commit is contained in:
2023-04-16 12:57:17 -04:00
parent 5c0c84a068
commit d6a2fd5a46
47 changed files with 3695 additions and 3768 deletions

View File

@@ -3,54 +3,53 @@ using FeedCenter.Options;
using System;
using System.Linq;
namespace FeedCenter
namespace FeedCenter;
public static class SettingsStore
{
public static class SettingsStore
public static object OpenDataStore()
{
public static object OpenDataStore()
if (!Database.Exists)
return null;
Database.Load();
return Database.Entities;
}
public static string GetSettingValue(object dataStore, string name, Version _)
{
var entities = (FeedCenterEntities) dataStore;
var setting = entities?.Settings.FirstOrDefault(s => s.Name == name);
return setting?.Value;
}
public static void SetSettingValue(object dataStore, string name, Version _, string value)
{
var entities = (FeedCenterEntities) dataStore;
if (entities == null)
return;
// Try to get the setting from the database that matches the name and version
var setting = entities.Settings.FirstOrDefault(s => s.Name == name);
entities.SaveChanges(() =>
{
if (!Database.Exists)
return null;
Database.Load();
return Database.Entities;
}
public static string GetSettingValue(object dataStore, string name, Version _)
{
var entities = (FeedCenterEntities) dataStore;
var setting = entities?.Settings.FirstOrDefault(s => s.Name == name);
return setting?.Value;
}
public static void SetSettingValue(object dataStore, string name, Version _, string value)
{
var entities = (FeedCenterEntities) dataStore;
if (entities == null)
return;
// Try to get the setting from the database that matches the name and version
var setting = entities.Settings.FirstOrDefault(s => s.Name == name);
entities.SaveChanges(() =>
// If there was no setting we need to create it
if (setting == null)
{
// If there was no setting we need to create it
if (setting == null)
{
// Create the new setting
setting = new Setting { Name = name };
// Create the new setting
setting = new Setting { Name = name };
// Add the setting to the database
entities.Settings.Add(setting);
}
// Add the setting to the database
entities.Settings.Add(setting);
}
// Set the value into the setting
setting.Value = value;
});
}
// Set the value into the setting
setting.Value = value;
});
}
}