2011-02-03 01:07:36 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
|
|
|
|
using SubSonic.Repository;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers
|
|
|
|
|
{
|
|
|
|
|
public class QualityProvider : IQualityProvider
|
|
|
|
|
{
|
|
|
|
|
private IRepository _sonicRepo;
|
|
|
|
|
|
|
|
|
|
public QualityProvider(IRepository sonicRepo)
|
|
|
|
|
{
|
|
|
|
|
_sonicRepo = sonicRepo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region IQualityProvider Members
|
|
|
|
|
|
2011-02-03 19:47:51 +00:00
|
|
|
|
public 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-02-03 19:47:51 +00:00
|
|
|
|
public void Update(QualityProfile profile)
|
2011-02-03 01:07:36 +00:00
|
|
|
|
{
|
|
|
|
|
if (!_sonicRepo.Exists<QualityProfile>(q => q.ProfileId == profile.ProfileId))
|
|
|
|
|
{
|
|
|
|
|
//Log Error
|
2011-02-03 19:47:51 +00:00
|
|
|
|
throw new InvalidOperationException("Unable to update none 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-02-03 19:47:51 +00:00
|
|
|
|
public void Delete(int profileId)
|
2011-02-03 01:07:36 +00:00
|
|
|
|
{
|
|
|
|
|
_sonicRepo.Delete<QualityProfile>(profileId);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-03 19:47:51 +00:00
|
|
|
|
public List<QualityProfile> GetAllProfiles()
|
2011-02-03 01:07:36 +00:00
|
|
|
|
{
|
|
|
|
|
var profiles = _sonicRepo.All<QualityProfile>().ToList();
|
|
|
|
|
|
|
|
|
|
return profiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|