sonarr-repo-only/NzbDrone.Core/Providers/SeasonProvider.cs

70 lines
2.1 KiB
C#
Raw Normal View History

2010-10-05 06:21:18 +00:00
using System;
using System.Collections.Generic;
using NLog;
using NzbDrone.Core.Repository;
2010-10-05 06:21:18 +00:00
using SubSonic.Repository;
using System.Linq;
2010-10-05 06:21:18 +00:00
namespace NzbDrone.Core.Providers
{
class SeasonProvider : ISeasonProvider
{
private readonly IRepository _sonicRepo;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
2010-10-05 06:21:18 +00:00
public SeasonProvider(IRepository dataRepository)
{
_sonicRepo = dataRepository;
}
public Season GetSeason(int seasonId)
{
return _sonicRepo.Single<Season>(seasonId);
2010-10-05 06:21:18 +00:00
}
2010-10-10 21:20:43 +00:00
public List<Season> GetSeasons(int seriesId)
2010-10-05 06:21:18 +00:00
{
return _sonicRepo.All<Season>().Where(s => s.SeriesId == seriesId).ToList();
2010-10-05 06:21:18 +00:00
}
public void EnsureSeason(int seriesId, int seasonId, int seasonNumber)
{
if (_sonicRepo.Exists<Season>(s => s.SeasonId == seasonId))
return;
//TODO: Calculate Season Folder
Logger.Trace("Adding Season To DB. [SeriesID:{0} SeasonID:{1} SeasonNumber:{2}]", seriesId, seasonId, seasonNumber, "????");
2010-10-05 06:21:18 +00:00
var newSeason = new Season()
{
Monitored = true,
SeasonId = seasonId,
SeasonNumber = seasonNumber,
SeriesId = seriesId
};
_sonicRepo.Add<Season>(newSeason);
}
public int SaveSeason(Season season)
{
throw new NotImplementedException();
}
public bool IsIgnored(int seasonId)
{
if (_sonicRepo.Single<Season>(seasonId).Monitored)
return true;
Logger.Debug("Season {0} is not wanted.");
return false;
}
public bool IsIgnored(int seriesId, int seasonNumber)
{
if (_sonicRepo.Single<Season>(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber).Monitored)
return true;
Logger.Debug("Season: {0} is not wanted for Series: {1}", seasonNumber, seriesId);
return false;
}
2010-10-05 06:21:18 +00:00
}
}