1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2025-01-18 21:29:46 +00:00
Sonarr/NzbDrone.Core/Tv/SeasonRepository.cs

40 lines
1.2 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Linq;
2013-05-05 21:24:33 +00:00
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Datastore;
2013-03-25 03:51:32 +00:00
namespace NzbDrone.Core.Tv
{
2013-09-10 05:22:38 +00:00
public interface ISeasonRepository : IBasicRepository<Series>
{
Season Get(int seriesId, int seasonNumber);
bool IsMonitored(int seriesId, int seasonNumber);
List<Season> GetSeasonBySeries(int seriesId);
}
2013-09-10 05:22:38 +00:00
public class SeasonRepository : BasicRepository<Series>, ISeasonRepository
{
2013-05-05 21:24:33 +00:00
public SeasonRepository(IDatabase database, IMessageAggregator messageAggregator)
: base(database, messageAggregator)
{
}
public Season Get(int seriesId, int seasonNumber)
{
2013-09-10 05:22:38 +00:00
var series = Query.Single(s => s.Id == seriesId);
return series.Seasons.Single(s => s.SeasonNumber == seasonNumber);
}
public bool IsMonitored(int seriesId, int seasonNumber)
{
2013-09-10 05:22:38 +00:00
var series = Query.Single(s => s.Id == seriesId);
return series.Seasons.Single(s => s.SeasonNumber == seasonNumber).Monitored;
}
public List<Season> GetSeasonBySeries(int seriesId)
{
2013-09-10 05:22:38 +00:00
return Query.Single(s => s.Id == seriesId).Seasons;
}
}
}