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-09-10 08:22:38 +03:00
|
|
|
public interface ISeasonRepository : IBasicRepository<Series>
|
2013-02-20 05:05:15 +03:00
|
|
|
{
|
|
|
|
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-09-10 08:22:38 +03:00
|
|
|
public class SeasonRepository : BasicRepository<Series>, ISeasonRepository
|
2013-02-20 05:05:15 +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 Season Get(int seriesId, int seasonNumber)
|
|
|
|
{
|
2013-09-10 08:22:38 +03:00
|
|
|
var series = Query.Single(s => s.Id == seriesId);
|
|
|
|
return series.Seasons.Single(s => 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-09-10 08:22:38 +03:00
|
|
|
var series = Query.Single(s => s.Id == seriesId);
|
|
|
|
return series.Seasons.Single(s => s.SeasonNumber == seasonNumber).Monitored;
|
2013-02-20 05:05:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<Season> GetSeasonBySeries(int seriesId)
|
|
|
|
{
|
2013-09-10 08:22:38 +03:00
|
|
|
return Query.Single(s => s.Id == seriesId).Seasons;
|
2013-02-20 05:05:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|