mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-31 12:00:06 -07:00
28 lines
881 B
C#
28 lines
881 B
C#
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;
|
|
}
|
|
}
|
|
}
|