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