54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using System.Linq;
|
|
|
|
namespace EnVisage.Code.BLL
|
|
{
|
|
public class SystemSettingsManager
|
|
{
|
|
private readonly EnVisageEntities _dbContext;
|
|
|
|
public SystemSettingsManager(EnVisageEntities dbContext = null)
|
|
{
|
|
if (dbContext == null)
|
|
{
|
|
_dbContext = new EnVisageEntities();
|
|
}
|
|
else
|
|
{
|
|
_dbContext = dbContext;
|
|
}
|
|
}
|
|
|
|
public string GetSystemSettingsValue(int type, bool exceptionOnSettingsNotFound = true)
|
|
{
|
|
var result = string.Empty;
|
|
var systemSetting = _dbContext.SystemSettings.FirstOrDefault(q => q.Type == type);
|
|
|
|
if (systemSetting == null)
|
|
{
|
|
if (exceptionOnSettingsNotFound)
|
|
{
|
|
string message = string.Format("System Setting not found in the settings store (Type = {0})", type);
|
|
throw new BLLException(message);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result = systemSetting.Value;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public int OptiMUSEThreshold()
|
|
{
|
|
var systemSetting = _dbContext.SystemSettings.FirstOrDefault(q => q.Type == (int)SystemSettingType.OptiMUSEThreshold);
|
|
var optiMUSEThreshold = 0;
|
|
if (systemSetting != null && int.TryParse(systemSetting.Value, out optiMUSEThreshold))
|
|
{
|
|
return optiMUSEThreshold;
|
|
}
|
|
return optiMUSEThreshold;
|
|
}
|
|
}
|
|
}
|