mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Seasons are now subdocuments of series
This commit is contained in:
parent
0861e5f8c1
commit
33986a9185
40 changed files with 256 additions and 633 deletions
|
@ -6,44 +6,35 @@ using NzbDrone.Core.Datastore;
|
|||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
public interface ISeasonRepository : IBasicRepository<Season>
|
||||
public interface ISeasonRepository : IBasicRepository<Series>
|
||||
{
|
||||
IList<int> GetSeasonNumbers(int seriesId);
|
||||
Season Get(int seriesId, int seasonNumber);
|
||||
bool IsMonitored(int seriesId, int seasonNumber);
|
||||
List<Season> GetSeasonBySeries(int seriesId);
|
||||
}
|
||||
|
||||
public class SeasonRepository : BasicRepository<Season>, ISeasonRepository
|
||||
public class SeasonRepository : BasicRepository<Series>, ISeasonRepository
|
||||
{
|
||||
|
||||
public SeasonRepository(IDatabase database, IMessageAggregator messageAggregator)
|
||||
: base(database, messageAggregator)
|
||||
{
|
||||
}
|
||||
|
||||
public IList<int> GetSeasonNumbers(int seriesId)
|
||||
{
|
||||
return Query.Where(c => c.SeriesId == seriesId).Select(c => c.SeasonNumber).ToList();
|
||||
}
|
||||
|
||||
public Season Get(int seriesId, int seasonNumber)
|
||||
{
|
||||
return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
|
||||
var series = Query.Single(s => s.Id == seriesId);
|
||||
return series.Seasons.Single(s => s.SeasonNumber == seasonNumber);
|
||||
}
|
||||
|
||||
public bool IsMonitored(int seriesId, int seasonNumber)
|
||||
{
|
||||
var season = Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
|
||||
|
||||
if (season == null) return true;
|
||||
|
||||
return season.Monitored;
|
||||
var series = Query.Single(s => s.Id == seriesId);
|
||||
return series.Seasons.Single(s => s.SeasonNumber == seasonNumber).Monitored;
|
||||
}
|
||||
|
||||
public List<Season> GetSeasonBySeries(int seriesId)
|
||||
{
|
||||
return Query.Where(s => s.SeriesId == seriesId);
|
||||
return Query.Single(s => s.Id == seriesId).Seasons;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue