2013-02-20 05:05:15 +03:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2013-05-06 00:24:33 +03:00
|
|
|
using NzbDrone.Common.Messaging;
|
2013-02-20 05:05:15 +03:00
|
|
|
using NzbDrone.Core.Datastore;
|
2013-03-25 06:51:32 +03:00
|
|
|
|
2013-02-20 05:05:15 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Tv
|
|
|
|
{
|
2013-03-24 07:16:00 +03:00
|
|
|
public interface ISeasonRepository : IBasicRepository<Season>
|
2013-02-20 05:05:15 +03:00
|
|
|
{
|
|
|
|
IList<int> GetSeasonNumbers(int seriesId);
|
|
|
|
Season Get(int seriesId, int seasonNumber);
|
2013-07-09 04:22:02 +03:00
|
|
|
bool IsMonitored(int seriesId, int seasonNumber);
|
2013-02-20 05:05:15 +03:00
|
|
|
List<Season> GetSeasonBySeries(int seriesId);
|
|
|
|
}
|
|
|
|
|
2013-03-24 07:16:00 +03:00
|
|
|
public class SeasonRepository : BasicRepository<Season>, ISeasonRepository
|
2013-02-20 05:05:15 +03:00
|
|
|
{
|
2013-03-24 03:08:23 +03:00
|
|
|
|
2013-05-06 00:24:33 +03:00
|
|
|
public SeasonRepository(IDatabase database, IMessageAggregator messageAggregator)
|
|
|
|
: base(database, messageAggregator)
|
2013-02-20 05:05:15 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public IList<int> GetSeasonNumbers(int seriesId)
|
|
|
|
{
|
2013-03-28 09:49:38 +03:00
|
|
|
return Query.Where(c => c.SeriesId == seriesId).Select(c => c.SeasonNumber).ToList();
|
2013-02-20 05:05:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public Season Get(int seriesId, int seasonNumber)
|
|
|
|
{
|
2013-03-27 06:44:52 +03:00
|
|
|
return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
|
2013-02-20 05:05:15 +03:00
|
|
|
}
|
|
|
|
|
2013-07-09 04:22:02 +03:00
|
|
|
public bool IsMonitored(int seriesId, int seasonNumber)
|
2013-02-20 05:05:15 +03:00
|
|
|
{
|
2013-03-27 06:44:52 +03:00
|
|
|
var season = Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
|
2013-02-25 03:00:17 +03:00
|
|
|
|
2013-07-09 04:22:02 +03:00
|
|
|
if (season == null) return true;
|
2013-02-25 03:00:17 +03:00
|
|
|
|
2013-07-09 04:22:02 +03:00
|
|
|
return season.Monitored;
|
2013-02-20 05:05:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<Season> GetSeasonBySeries(int seriesId)
|
|
|
|
{
|
2013-03-27 06:44:52 +03:00
|
|
|
return Query.Where(s => s.SeriesId == seriesId);
|
2013-02-20 05:05:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|