2013-02-20 03:05:15 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Core.Datastore;
|
2013-03-02 19:25:39 +01:00
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Tv
|
|
|
|
{
|
|
|
|
public interface ISeasonRepository : IBasicRepository<Season>
|
|
|
|
{
|
|
|
|
IList<int> GetSeasonNumbers(int seriesId);
|
|
|
|
Season Get(int seriesId, int seasonNumber);
|
|
|
|
bool IsIgnored(int seriesId, int seasonNumber);
|
|
|
|
List<Season> GetSeasonBySeries(int seriesId);
|
|
|
|
}
|
|
|
|
|
|
|
|
public class SeasonRepository : BasicRepository<Season>, ISeasonRepository
|
|
|
|
{
|
|
|
|
public SeasonRepository(IObjectDatabase database)
|
|
|
|
: base(database)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public IList<int> GetSeasonNumbers(int seriesId)
|
|
|
|
{
|
|
|
|
return Queryable.Where(c => c.SeriesId == seriesId).Select(c => c.SeasonNumber).ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Season Get(int seriesId, int seasonNumber)
|
|
|
|
{
|
|
|
|
return Queryable.Single(c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsIgnored(int seriesId, int seasonNumber)
|
|
|
|
{
|
2013-02-26 04:58:57 +01:00
|
|
|
var season = Queryable.SingleOrDefault(c => c.Id == seriesId && c.SeasonNumber == seasonNumber);
|
2013-02-25 01:00:17 +01:00
|
|
|
|
|
|
|
if(season == null) return false;
|
|
|
|
|
|
|
|
return season.Ignored;
|
2013-02-20 03:05:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<Season> GetSeasonBySeries(int seriesId)
|
|
|
|
{
|
|
|
|
return Queryable.Where(c => c.SeriesId == seriesId).ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|