1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-28 10:48:46 +00:00
Sonarr/NzbDrone.Core/Tv/SeasonRepository.cs

49 lines
1.4 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-03-24 04:16:00 +00:00
public interface ISeasonRepository : IBasicRepository<Season>
{
IList<int> GetSeasonNumbers(int seriesId);
Season Get(int seriesId, int seasonNumber);
bool IsMonitored(int seriesId, int seasonNumber);
List<Season> GetSeasonBySeries(int seriesId);
}
2013-03-24 04:16:00 +00:00
public class SeasonRepository : BasicRepository<Season>, ISeasonRepository
{
2013-03-24 00:08:23 +00:00
2013-05-05 21:24:33 +00:00
public SeasonRepository(IDatabase database, IMessageAggregator messageAggregator)
: base(database, messageAggregator)
{
}
public IList<int> GetSeasonNumbers(int seriesId)
{
2013-03-28 06:49:38 +00:00
return Query.Where(c => c.SeriesId == seriesId).Select(c => c.SeasonNumber).ToList();
}
public Season Get(int seriesId, int seasonNumber)
{
2013-03-27 03:44:52 +00:00
return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
}
public bool IsMonitored(int seriesId, int seasonNumber)
{
2013-03-27 03:44:52 +00:00
var season = Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
2013-02-25 00:00:17 +00:00
if (season == null) return true;
2013-02-25 00:00:17 +00:00
return season.Monitored;
}
public List<Season> GetSeasonBySeries(int seriesId)
{
2013-03-27 03:44:52 +00:00
return Query.Where(s => s.SeriesId == seriesId);
}
}
}