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.
Lidarr/NzbDrone.Core/Tv/SeasonRepository.cs

50 lines
1.5 KiB

using System.Collections.Generic;
using System.Data;
using System.Linq;
using NzbDrone.Core.Datastore;
using ServiceStack.OrmLite;
namespace NzbDrone.Core.Tv
{
12 years ago
public interface ISeasonRepository : IBasicRepository<Season>
{
IList<int> GetSeasonNumbers(int seriesId);
Season Get(int seriesId, int seasonNumber);
bool IsIgnored(int seriesId, int seasonNumber);
List<Season> GetSeasonBySeries(int seriesId);
}
12 years ago
public class SeasonRepository : BasicRepository<Season>, ISeasonRepository
{
private readonly IDbConnection _database;
public SeasonRepository(IDbConnection database)
: base(database)
{
}
public IList<int> GetSeasonNumbers(int seriesId)
{
return _database.List<int>("SELECT SeasonNumber WHERE SeriesId = {0}", seriesId);
}
public Season Get(int seriesId, int seasonNumber)
{
return _database.Select<Season>(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber).Single();
}
public bool IsIgnored(int seriesId, int seasonNumber)
{
var season = _database.Select<Season>(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber).SingleOrDefault();
12 years ago
if(season == null) return false;
return season.Ignored;
}
public List<Season> GetSeasonBySeries(int seriesId)
{
return _database.Select<Season>(s => s.SeriesId == seriesId);
}
}
}