2013-08-27 03:20:03 +00:00
|
|
|
|
using System;
|
2013-03-03 22:26:41 +00:00
|
|
|
|
using System.Collections.Generic;
|
2012-02-21 03:25:19 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
2013-04-24 01:56:00 +00:00
|
|
|
|
using NzbDrone.Common.Messaging;
|
2013-08-05 09:09:41 +00:00
|
|
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
2013-03-03 22:26:41 +00:00
|
|
|
|
using NzbDrone.Core.Tv.Events;
|
2012-02-21 03:25:19 +00:00
|
|
|
|
|
2013-02-19 06:01:03 +00:00
|
|
|
|
namespace NzbDrone.Core.Tv
|
2012-02-21 03:25:19 +00:00
|
|
|
|
{
|
2013-02-20 02:05:15 +00:00
|
|
|
|
public interface ISeasonService
|
2012-02-21 03:25:19 +00:00
|
|
|
|
{
|
2013-09-10 05:22:38 +00:00
|
|
|
|
// void SetMonitored(int seriesId, int seasonNumber, bool monitored);
|
|
|
|
|
// List<Season> SetSeasonPass(int seriesId, int seasonNumber);
|
2013-03-03 22:26:41 +00:00
|
|
|
|
List<Season> GetSeasonsBySeries(int seriesId);
|
2013-08-05 09:09:41 +00:00
|
|
|
|
List<Season> GetAllSeasons();
|
2013-02-20 02:05:15 +00:00
|
|
|
|
}
|
2012-02-21 03:25:19 +00:00
|
|
|
|
|
2013-09-10 05:22:38 +00:00
|
|
|
|
public class SeasonService : ISeasonService
|
2013-02-20 02:05:15 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly ISeasonRepository _seasonRepository;
|
2013-08-07 01:25:06 +00:00
|
|
|
|
private readonly IEpisodeService _episodeService;
|
2013-02-20 02:05:15 +00:00
|
|
|
|
private readonly Logger _logger;
|
2012-02-21 03:25:19 +00:00
|
|
|
|
|
2013-08-07 01:25:06 +00:00
|
|
|
|
public SeasonService(ISeasonRepository seasonRepository, IEpisodeService episodeService, Logger logger)
|
2012-02-21 03:25:19 +00:00
|
|
|
|
{
|
2013-02-20 02:05:15 +00:00
|
|
|
|
_seasonRepository = seasonRepository;
|
2013-07-10 02:11:00 +00:00
|
|
|
|
_episodeService = episodeService;
|
2013-02-20 02:05:15 +00:00
|
|
|
|
_logger = logger;
|
2012-02-21 03:25:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-10 05:22:38 +00:00
|
|
|
|
// public void SetMonitored(int seriesId, int seasonNumber, bool monitored)
|
|
|
|
|
// {
|
|
|
|
|
// var season = _seasonRepository.Get(seriesId, seasonNumber);
|
|
|
|
|
//
|
|
|
|
|
// _logger.Trace("Setting monitored flag on Series:{0} Season:{1} to {2}", seriesId, seasonNumber, monitored);
|
|
|
|
|
//
|
|
|
|
|
// season.Monitored = monitored;
|
|
|
|
|
// _episodeService.SetEpisodeMonitoredBySeason(seriesId, seasonNumber, monitored);
|
|
|
|
|
// _seasonRepository.Update(season);
|
|
|
|
|
//
|
|
|
|
|
// _logger.Info("Monitored flag for Series:{0} Season:{1} successfully set to {2}", seriesId, seasonNumber, monitored);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// public List<Season> SetSeasonPass(int seriesId, int seasonNumber)
|
|
|
|
|
// {
|
|
|
|
|
// _logger.Trace("Setting up Season Pass for {0} starting with season: {0}", seriesId, seasonNumber);
|
|
|
|
|
//
|
|
|
|
|
// var seasons = GetSeasonsBySeries(seriesId);
|
|
|
|
|
//
|
|
|
|
|
// foreach (var season in seasons)
|
|
|
|
|
// {
|
|
|
|
|
// if (season.SeasonNumber >= seasonNumber)
|
|
|
|
|
// {
|
|
|
|
|
// _logger.Trace("Setting monitored flag on Series:{0} Season:{1} to {2}", seriesId, seasonNumber, true);
|
|
|
|
|
// season.Monitored = true;
|
|
|
|
|
// _episodeService.SetEpisodeMonitoredBySeason(seriesId, season.SeasonNumber, true);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// _logger.Trace("Setting monitored flag on Series:{0} Season:{1} to {2}", seriesId, seasonNumber, false);
|
|
|
|
|
// season.Monitored = false;
|
|
|
|
|
// _episodeService.SetEpisodeMonitoredBySeason(seriesId, season.SeasonNumber, false);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// _seasonRepository.UpdateMany(seasons);
|
|
|
|
|
// _logger.Trace("Season Pass set for {0} starting with season: {0}", seriesId, seasonNumber);
|
|
|
|
|
//
|
|
|
|
|
// return seasons;
|
|
|
|
|
// }
|
2013-03-03 22:26:41 +00:00
|
|
|
|
|
|
|
|
|
public List<Season> GetSeasonsBySeries(int seriesId)
|
|
|
|
|
{
|
|
|
|
|
return _seasonRepository.GetSeasonBySeries(seriesId);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-05 09:09:41 +00:00
|
|
|
|
public List<Season> GetAllSeasons()
|
|
|
|
|
{
|
2013-09-10 05:22:38 +00:00
|
|
|
|
return _seasonRepository.All().SelectMany(s => s.Seasons).ToList();
|
2013-03-05 19:49:34 +00:00
|
|
|
|
}
|
2013-02-20 02:05:15 +00:00
|
|
|
|
}
|
2012-02-21 03:25:19 +00:00
|
|
|
|
} |