You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/src/Ombi.Core/Services/FeatureService.cs

29 lines
881 B

using Ombi.Core.Settings;
using Ombi.Settings.Settings.Models;
using System.Linq;
using System.Threading.Tasks;
namespace Ombi.Core.Services
{
public interface IFeatureService
{
Task<bool> FeatureEnabled(string featureName);
}
public class FeatureService : IFeatureService
{
private readonly ISettingsService<FeatureSettings> _featureSettings;
public FeatureService(ISettingsService<FeatureSettings> featureSettings)
{
_featureSettings = featureSettings;
}
public async Task<bool> FeatureEnabled(string featureName)
{
var settings = await _featureSettings.GetSettingsAsync();
return settings.Features?.Where(x => x.Name.Equals(featureName, System.StringComparison.InvariantCultureIgnoreCase)).Select(x => x.Enabled)?.FirstOrDefault() ?? false;
}
}
}