rdt-client/server/RdtClient.Service/Helpers/SettingsHelper.cs
Roger Far cd6002b5d6 Upgrade packages
Moved C# code to file scoped namespaces
Merged Startup.cs and Program.cs
2022-04-30 11:22:15 -06:00

30 lines
No EOL
751 B
C#

using RdtClient.Data.Models.Data;
namespace RdtClient.Service.Helpers;
public static class SettingsHelper
{
public static String GetString(this IList<Setting> settings, String key)
{
var setting = settings.FirstOrDefault(m => m.SettingId == key);
if (setting == null)
{
throw new Exception($"Setting with key {key} not found");
}
return setting.Value;
}
public static Int32 GetNumber(this IList<Setting> settings, String key)
{
var setting = settings.FirstOrDefault(m => m.SettingId == key);
if (setting == null)
{
throw new Exception($"Setting with key {key} not found");
}
return Int32.Parse(setting.Value);
}
}