diff --git a/src/NzbDrone.Api/Calendar/CalendarModule.cs b/src/NzbDrone.Api/Calendar/CalendarModule.cs index 372515e64..8a047ddb4 100644 --- a/src/NzbDrone.Api/Calendar/CalendarModule.cs +++ b/src/NzbDrone.Api/Calendar/CalendarModule.cs @@ -3,7 +3,6 @@ using System.Linq; using NzbDrone.Api.Episodes; using NzbDrone.Api.Extensions; -using NzbDrone.Api.Mapping; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Tv; @@ -17,7 +16,7 @@ public class CalendarModule : EpisodeModuleWithSignalR public CalendarModule(ICommandExecutor commandExecutor, IEpisodeService episodeService, SeriesRepository seriesRepository) - : base(commandExecutor, "calendar") + : base(episodeService, commandExecutor, "calendar") { _episodeService = episodeService; _seriesRepository = seriesRepository; @@ -26,11 +25,6 @@ public CalendarModule(ICommandExecutor commandExecutor, GetResourceById = GetEpisode; } - private EpisodeResource GetEpisode(int id) - { - return _episodeService.GetEpisode(id).InjectTo(); - } - private List GetCalendar() { var start = DateTime.Today; diff --git a/src/NzbDrone.Api/Episodes/EpisodeModule.cs b/src/NzbDrone.Api/Episodes/EpisodeModule.cs index 0fc9fb59b..7d72b5204 100644 --- a/src/NzbDrone.Api/Episodes/EpisodeModule.cs +++ b/src/NzbDrone.Api/Episodes/EpisodeModule.cs @@ -1,9 +1,5 @@ using System.Collections.Generic; -using NzbDrone.Api.Mapping; using NzbDrone.Api.REST; -using NzbDrone.Core.Datastore.Events; -using NzbDrone.Core.Download; -using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Tv; @@ -15,7 +11,7 @@ public class EpisodeModule : EpisodeModuleWithSignalR private readonly IEpisodeService _episodeService; public EpisodeModule(ICommandExecutor commandExecutor, IEpisodeService episodeService) - : base(commandExecutor) + : base(episodeService, commandExecutor) { _episodeService = episodeService; @@ -40,29 +36,5 @@ private void SetMonitored(EpisodeResource episodeResource) { _episodeService.SetEpisodeMonitored(episodeResource.Id, episodeResource.Monitored); } - - private EpisodeResource GetEpisode(int id) - { - return _episodeService.GetEpisode(id).InjectTo(); - } - - public void Handle(EpisodeGrabbedEvent message) - { - foreach (var episode in message.Episode.Episodes) - { - var resource = episode.InjectTo(); - resource.Grabbed = true; - - BroadcastResourceChange(ModelAction.Updated, resource); - } - } - - public void Handle(EpisodeDownloadedEvent message) - { - foreach (var episode in message.Episode.Episodes) - { - BroadcastResourceChange(ModelAction.Updated, episode.Id); - } - } } } \ No newline at end of file diff --git a/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs b/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs index 8a305eb1b..c90374f40 100644 --- a/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs +++ b/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs @@ -14,14 +14,23 @@ public abstract class EpisodeModuleWithSignalR : NzbDroneRest where TResource : EpisodeResource, new() where TModel : Episode { - protected EpisodeModuleWithSignalR(ICommandExecutor commandExecutor) + private readonly IEpisodeService _episodeService; + + protected EpisodeModuleWithSignalR(IEpisodeService episodeService, ICommandExecutor commandExecutor) : base(commandExecutor) { + _episodeService = episodeService; } - protected EpisodeModuleWithSignalR(ICommandExecutor commandExecutor, string resource) + protected EpisodeModuleWithSignalR(IEpisodeService episodeService, ICommandExecutor commandExecutor, string resource) : base(commandExecutor, resource) { + _episodeService = episodeService; + } + + protected EpisodeResource GetEpisode(int id) + { + return _episodeService.GetEpisode(id).InjectTo(); } public void Handle(EpisodeGrabbedEvent message) diff --git a/src/NzbDrone.Api/Wanted/CutoffModule.cs b/src/NzbDrone.Api/Wanted/CutoffModule.cs index a9ab765e2..75d3ffbcc 100644 --- a/src/NzbDrone.Api/Wanted/CutoffModule.cs +++ b/src/NzbDrone.Api/Wanted/CutoffModule.cs @@ -12,8 +12,8 @@ public class CutoffModule : EpisodeModuleWithSignalR private readonly IEpisodeCutoffService _episodeCutoffService; private readonly ISeriesRepository _seriesRepository; - public CutoffModule(IEpisodeCutoffService episodeCutoffService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor) - :base(commandExecutor, "wanted/cutoff") + public CutoffModule(IEpisodeService episodeService, IEpisodeCutoffService episodeCutoffService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor) + :base(episodeService, commandExecutor, "wanted/cutoff") { _episodeCutoffService = episodeCutoffService; _seriesRepository = seriesRepository; diff --git a/src/NzbDrone.Api/Wanted/MissingModule.cs b/src/NzbDrone.Api/Wanted/MissingModule.cs index 81b8d17cf..44338b888 100644 --- a/src/NzbDrone.Api/Wanted/MissingModule.cs +++ b/src/NzbDrone.Api/Wanted/MissingModule.cs @@ -13,7 +13,7 @@ public class MissingModule : EpisodeModuleWithSignalR private readonly ISeriesRepository _seriesRepository; public MissingModule(IEpisodeService episodeService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor) - :base(commandExecutor, "wanted/missing") + :base(episodeService, commandExecutor, "wanted/missing") { _episodeService = episodeService; _seriesRepository = seriesRepository;