2013-02-20 03:05:15 +01:00
|
|
|
using System.Collections.Generic;
|
2013-03-24 01:08:23 +01:00
|
|
|
using System.Data;
|
2013-02-20 03:05:15 +01:00
|
|
|
using System.Linq;
|
|
|
|
using NzbDrone.Core.Datastore;
|
2013-03-25 04:51:32 +01:00
|
|
|
|
2013-02-20 03:05:15 +01:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Tv
|
|
|
|
{
|
2013-03-24 05:16:00 +01:00
|
|
|
public interface ISeasonRepository : IBasicRepository<Season>
|
2013-02-20 03:05:15 +01:00
|
|
|
{
|
|
|
|
IList<int> GetSeasonNumbers(int seriesId);
|
|
|
|
Season Get(int seriesId, int seasonNumber);
|
|
|
|
bool IsIgnored(int seriesId, int seasonNumber);
|
|
|
|
List<Season> GetSeasonBySeries(int seriesId);
|
|
|
|
}
|
|
|
|
|
2013-03-24 05:16:00 +01:00
|
|
|
public class SeasonRepository : BasicRepository<Season>, ISeasonRepository
|
2013-02-20 03:05:15 +01:00
|
|
|
{
|
2013-03-24 01:08:23 +01:00
|
|
|
private readonly IDbConnection _database;
|
|
|
|
|
2013-03-25 04:51:32 +01:00
|
|
|
public SeasonRepository(IDatabase database)
|
2013-03-24 01:08:23 +01:00
|
|
|
: base(database)
|
2013-02-20 03:05:15 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public IList<int> GetSeasonNumbers(int seriesId)
|
|
|
|
{
|
2013-03-27 04:44:52 +01:00
|
|
|
return Query.Where(c => c.SeriesId == seriesId).Select(c => c.SeriesId).ToList();
|
2013-02-20 03:05:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Season Get(int seriesId, int seasonNumber)
|
|
|
|
{
|
2013-03-27 04:44:52 +01:00
|
|
|
return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
|
2013-02-20 03:05:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsIgnored(int seriesId, int seasonNumber)
|
|
|
|
{
|
2013-03-27 04:44:52 +01:00
|
|
|
var season = Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
|
2013-02-25 01:00:17 +01:00
|
|
|
|
2013-03-25 04:51:32 +01:00
|
|
|
if (season == null) return false;
|
2013-02-25 01:00:17 +01:00
|
|
|
|
|
|
|
return season.Ignored;
|
2013-02-20 03:05:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<Season> GetSeasonBySeries(int seriesId)
|
|
|
|
{
|
2013-03-27 04:44:52 +01:00
|
|
|
return Query.Where(s => s.SeriesId == seriesId);
|
2013-02-20 03:05:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|