2013-11-14 05:02:27 +03:00
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Organizer
|
|
|
|
{
|
|
|
|
public interface INamingConfigService
|
|
|
|
{
|
|
|
|
NamingConfig GetConfig();
|
|
|
|
void Save(NamingConfig namingConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
public class NamingConfigService : INamingConfigService
|
|
|
|
{
|
2015-05-03 21:46:21 +02:00
|
|
|
private readonly INamingConfigRepository _repository;
|
2013-11-14 05:02:27 +03:00
|
|
|
|
2015-05-03 21:46:21 +02:00
|
|
|
public NamingConfigService(INamingConfigRepository repository)
|
2013-11-14 05:02:27 +03:00
|
|
|
{
|
|
|
|
_repository = repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
public NamingConfig GetConfig()
|
|
|
|
{
|
|
|
|
var config = _repository.SingleOrDefault();
|
|
|
|
|
|
|
|
if (config == null)
|
|
|
|
{
|
|
|
|
_repository.Insert(NamingConfig.Default);
|
|
|
|
config = _repository.Single();
|
|
|
|
}
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Save(NamingConfig namingConfig)
|
|
|
|
{
|
|
|
|
_repository.Upsert(namingConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|