You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Radarr/NzbDrone.Core/Tv/SeasonRepository.cs

49 lines
1.4 KiB

using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.Tv
{
12 years ago
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);
}
12 years ago
public class SeasonRepository : BasicRepository<Season>, 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);
}
public bool IsMonitored(int seriesId, int seasonNumber)
{
var season = Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
12 years ago
if (season == null) return true;
12 years ago
return season.Monitored;
}
public List<Season> GetSeasonBySeries(int seriesId)
{
return Query.Where(s => s.SeriesId == seriesId);
}
}
}