mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-31 07:52:37 +01:00
39 lines
4.8 KiB
C#
39 lines
4.8 KiB
C#
using System.Linq;
|
||
using NLog;
|
||
|
||
namespace NzbDrone.Core.Tv
|
||
{
|
||
public interface ISeasonService
|
||
{
|
||
void SetIgnore(int seriesId, int seasonNumber, bool isIgnored);
|
||
}
|
||
|
||
public class SeasonService : ISeasonService
|
||
{
|
||
private readonly ISeasonRepository _seasonRepository;
|
||
private readonly Logger _logger;
|
||
|
||
public SeasonService(ISeasonRepository seasonRepository,Logger logger)
|
||
{
|
||
_seasonRepository = seasonRepository;
|
||
_logger = logger;
|
||
}
|
||
|
||
|
||
public void SetIgnore(int seriesId, int seasonNumber, bool isIgnored)
|
||
{
|
||
var season = _seasonRepository.Get(seriesId, seasonNumber);
|
||
|
||
_logger.Trace("Setting ignore flag on Series:{0} Season:{1} to {2}", seriesId, seasonNumber, isIgnored);
|
||
|
||
season.Ignored = isIgnored;
|
||
season.Episodes.ForEach(e=>e.Ignored = isIgnored);
|
||
|
||
_seasonRepository.Update(season);
|
||
|
||
_logger.Info("Ignore flag for Series:{0} Season:{1} successfully set to {2}", seriesId, seasonNumber, isIgnored);
|
||
}
|
||
}
|
||
|
||
|
||
} |