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.
Readarr/NzbDrone.Core/Tv/SeriesRepository.cs

50 lines
1.5 KiB

using System;
using System.Linq;
12 years ago
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events;
11 years ago
12 years ago
namespace NzbDrone.Core.Tv
{
12 years ago
public interface ISeriesRepository : IBasicRepository<Series>
12 years ago
{
bool SeriesPathExists(string path);
Series FindByTitle(string cleanTitle);
12 years ago
Series FindByTvdbId(int tvdbId);
Series FindByTvRageId(int tvRageId);
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
12 years ago
}
12 years ago
public class SeriesRepository : BasicRepository<Series>, ISeriesRepository
12 years ago
{
public SeriesRepository(IDatabase database, IEventAggregator eventAggregator)
: base(database, eventAggregator)
12 years ago
{
}
public bool SeriesPathExists(string path)
{
return Query.Any(c => c.Path == path);
12 years ago
}
public Series FindByTitle(string cleanTitle)
12 years ago
{
return Query.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle, StringComparison.InvariantCultureIgnoreCase));
12 years ago
}
12 years ago
public Series FindByTvdbId(int tvdbId)
{
return Query.SingleOrDefault(s => s.TvdbId.Equals(tvdbId));
12 years ago
}
public Series FindByTvRageId(int tvRageId)
{
return Query.SingleOrDefault(s => s.TvRageId.Equals(tvRageId));
}
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
12 years ago
{
SetFields(new Series { Id = seriesId, SeriesType = seriesType }, s => s.SeriesType);
12 years ago
}
12 years ago
}
}