You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
960 B
34 lines
960 B
using System;
|
|
using System.Linq;
|
|
using NzbDrone.Core.Datastore;
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
|
|
namespace NzbDrone.Core.Qualities
|
|
{
|
|
public interface IQualityDefinitionRepository : IBasicRepository<QualityDefinition>
|
|
{
|
|
QualityDefinition GetByQualityId(int qualityId);
|
|
}
|
|
|
|
public class QualityDefinitionRepository : BasicRepository<QualityDefinition>, IQualityDefinitionRepository
|
|
{
|
|
public QualityDefinitionRepository(IDatabase database, IEventAggregator eventAggregator)
|
|
: base(database, eventAggregator)
|
|
{
|
|
}
|
|
|
|
public QualityDefinition GetByQualityId(int qualityId)
|
|
{
|
|
try
|
|
{
|
|
return Query.Where(q => (int) q.Quality == qualityId).Single();
|
|
}
|
|
catch (InvalidOperationException)
|
|
{
|
|
throw new ModelNotFoundException(typeof(QualityDefinition), qualityId);
|
|
}
|
|
}
|
|
}
|
|
}
|