using Microsoft.EntityFrameworkCore;
using OliverBooth.Data;
namespace OliverBooth.Services;
///
/// Represents a service for retrieving configuration values.
///
public sealed class ConfigurationService
{
private readonly IDbContextFactory _webContextFactory;
///
/// Initializes a new instance of the class.
///
///
/// The for the .
///
public ConfigurationService(IDbContextFactory webContextFactory)
{
_webContextFactory = webContextFactory;
}
///
/// Gets the value of a site configuration key.
///
/// The key of the site configuration item.
/// The value of the site configuration item.
public string? GetSiteConfiguration(string key)
{
using WebContext context = _webContextFactory.CreateDbContext();
return context.SiteConfiguration.Find(key)?.Value;
}
}