2012-02-21 03:25:19 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
|
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-02-20 02:05:15 +00:00
|
|
|
|
void SetIgnore(int seriesId, int seasonNumber, bool isIgnored);
|
|
|
|
|
}
|
2012-02-21 03:25:19 +00:00
|
|
|
|
|
2013-02-20 02:05:15 +00:00
|
|
|
|
public class SeasonService : ISeasonService
|
|
|
|
|
{
|
|
|
|
|
private readonly ISeasonRepository _seasonRepository;
|
|
|
|
|
private readonly Logger _logger;
|
2012-02-21 03:25:19 +00:00
|
|
|
|
|
2013-02-20 02:05:15 +00:00
|
|
|
|
public SeasonService(ISeasonRepository seasonRepository,Logger logger)
|
2012-02-21 03:25:19 +00:00
|
|
|
|
{
|
2013-02-20 02:05:15 +00:00
|
|
|
|
_seasonRepository = seasonRepository;
|
|
|
|
|
_logger = logger;
|
2012-02-21 03:25:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-02-20 02:05:15 +00:00
|
|
|
|
public void SetIgnore(int seriesId, int seasonNumber, bool isIgnored)
|
2012-02-21 03:25:19 +00:00
|
|
|
|
{
|
2013-02-20 02:05:15 +00:00
|
|
|
|
var season = _seasonRepository.Get(seriesId, seasonNumber);
|
2012-02-21 03:25:19 +00:00
|
|
|
|
|
2013-02-20 02:05:15 +00:00
|
|
|
|
_logger.Trace("Setting ignore flag on Series:{0} Season:{1} to {2}", seriesId, seasonNumber, isIgnored);
|
2012-02-28 05:50:56 +00:00
|
|
|
|
|
2013-02-20 02:05:15 +00:00
|
|
|
|
season.Ignored = isIgnored;
|
|
|
|
|
season.Episodes.ForEach(e=>e.Ignored = isIgnored);
|
2012-02-28 05:50:56 +00:00
|
|
|
|
|
2013-02-20 02:05:15 +00:00
|
|
|
|
_seasonRepository.Update(season);
|
2012-02-21 03:25:19 +00:00
|
|
|
|
|
2013-02-20 02:05:15 +00:00
|
|
|
|
_logger.Info("Ignore flag for Series:{0} Season:{1} successfully set to {2}", seriesId, seasonNumber, isIgnored);
|
2012-02-21 03:25:19 +00:00
|
|
|
|
}
|
2013-02-20 02:05:15 +00:00
|
|
|
|
}
|
2012-02-21 06:50:38 +00:00
|
|
|
|
|
2012-02-28 05:50:56 +00:00
|
|
|
|
|
2012-02-21 03:25:19 +00:00
|
|
|
|
} |