2011-02-03 02:07:36 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2011-04-08 06:03:46 +02:00
|
|
|
|
using System.Diagnostics;
|
2011-02-03 02:07:36 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2011-02-04 03:58:02 +01:00
|
|
|
|
using NLog;
|
2011-02-03 02:07:36 +01:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
|
|
|
|
using SubSonic.Repository;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers
|
|
|
|
|
{
|
2011-04-08 06:03:46 +02:00
|
|
|
|
public class QualityProvider
|
2011-02-03 02:07:36 +01:00
|
|
|
|
{
|
|
|
|
|
private IRepository _sonicRepo;
|
2011-02-04 03:58:02 +01:00
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
2011-02-03 02:07:36 +01:00
|
|
|
|
|
2011-04-08 08:50:30 +02:00
|
|
|
|
public QualityProvider()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2011-04-08 06:03:46 +02:00
|
|
|
|
|
2011-02-03 02:07:36 +01:00
|
|
|
|
public QualityProvider(IRepository sonicRepo)
|
|
|
|
|
{
|
|
|
|
|
_sonicRepo = sonicRepo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region IQualityProvider Members
|
|
|
|
|
|
2011-04-08 06:03:46 +02:00
|
|
|
|
public virtual void Add(QualityProfile profile)
|
2011-02-03 02:07:36 +01:00
|
|
|
|
{
|
2011-02-03 20:47:51 +01:00
|
|
|
|
_sonicRepo.Add(profile);
|
2011-02-03 02:07:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 06:03:46 +02:00
|
|
|
|
public virtual void Update(QualityProfile profile)
|
2011-02-03 02:07:36 +01:00
|
|
|
|
{
|
2011-02-17 18:45:02 +01:00
|
|
|
|
if (!_sonicRepo.Exists<QualityProfile>(q => q.QualityProfileId == profile.QualityProfileId))
|
2011-02-03 02:07:36 +01:00
|
|
|
|
{
|
2011-02-04 03:58:02 +01:00
|
|
|
|
Logger.Error("Unable to update non-existing profile");
|
|
|
|
|
throw new InvalidOperationException("Unable to update non-existing profile");
|
2011-02-03 02:07:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-03 20:47:51 +01:00
|
|
|
|
_sonicRepo.Update(profile);
|
2011-02-03 02:07:36 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 06:03:46 +02:00
|
|
|
|
public virtual void Delete(int profileId)
|
2011-02-03 02:07:36 +01:00
|
|
|
|
{
|
|
|
|
|
_sonicRepo.Delete<QualityProfile>(profileId);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 06:03:46 +02:00
|
|
|
|
public virtual List<QualityProfile> GetAllProfiles()
|
2011-02-03 02:07:36 +01:00
|
|
|
|
{
|
|
|
|
|
var profiles = _sonicRepo.All<QualityProfile>().ToList();
|
|
|
|
|
|
|
|
|
|
return profiles;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 06:03:46 +02:00
|
|
|
|
public virtual QualityProfile Find(int profileId)
|
2011-02-05 07:07:25 +01:00
|
|
|
|
{
|
2011-02-17 18:45:02 +01:00
|
|
|
|
return _sonicRepo.Single<QualityProfile>(q => q.QualityProfileId == profileId);
|
2011-02-05 07:07:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-03 02:07:36 +01:00
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|