diff --git a/src/NzbDrone.Core/Applications/AppIndexerMapService.cs b/src/NzbDrone.Core/Applications/AppIndexerMapService.cs index 41c812fe1..cdfd59bd2 100644 --- a/src/NzbDrone.Core/Applications/AppIndexerMapService.cs +++ b/src/NzbDrone.Core/Applications/AppIndexerMapService.cs @@ -8,6 +8,7 @@ namespace NzbDrone.Core.Applications { List GetMappingsForApp(int appId); AppIndexerMap Insert(AppIndexerMap appIndexerMap); + void Delete(int mappingId); void DeleteAllForApp(int appId); } @@ -25,6 +26,11 @@ namespace NzbDrone.Core.Applications _appIndexerMapRepository.DeleteAllForApp(appId); } + public void Delete(int mappingId) + { + _appIndexerMapRepository.Delete(mappingId); + } + public List GetMappingsForApp(int appId) { return _appIndexerMapRepository.GetMappingsForApp(appId); diff --git a/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs b/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs index 0fc08aed3..5a638df22 100644 --- a/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs +++ b/src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs @@ -47,8 +47,16 @@ namespace NzbDrone.Core.Applications.Lidarr public override void RemoveIndexer(int indexerId) { - //Use the Id mapping here to delete the correct indexer - throw new System.NotImplementedException(); + var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); + + var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexerId); + + if (indexerMapping != null) + { + //Remove Indexer remotely and then remove the mapping + _lidarrV1Proxy.RemoveIndexer(indexerMapping.RemoteIndexerId, Settings); + _appIndexerMapService.Delete(indexerMapping.Id); + } } public override void UpdateIndexer(IndexerDefinition indexer) diff --git a/src/NzbDrone.Core/Applications/Lidarr/LidarrV1Proxy.cs b/src/NzbDrone.Core/Applications/Lidarr/LidarrV1Proxy.cs index a62f9761e..adc72a12a 100644 --- a/src/NzbDrone.Core/Applications/Lidarr/LidarrV1Proxy.cs +++ b/src/NzbDrone.Core/Applications/Lidarr/LidarrV1Proxy.cs @@ -14,6 +14,7 @@ namespace NzbDrone.Core.Applications.Lidarr LidarrIndexer AddIndexer(LidarrIndexer indexer, LidarrSettings settings); List GetIndexers(LidarrSettings settings); List GetIndexerSchema(LidarrSettings settings); + void RemoveIndexer(int indexerId, LidarrSettings settings); ValidationFailure Test(LidarrSettings settings); } diff --git a/src/NzbDrone.Core/Applications/Radarr/Radarr.cs b/src/NzbDrone.Core/Applications/Radarr/Radarr.cs index fd0915ae5..c06ef0b7c 100644 --- a/src/NzbDrone.Core/Applications/Radarr/Radarr.cs +++ b/src/NzbDrone.Core/Applications/Radarr/Radarr.cs @@ -47,8 +47,16 @@ namespace NzbDrone.Core.Applications.Radarr public override void RemoveIndexer(int indexerId) { - //Use the Id mapping here to delete the correct indexer - throw new System.NotImplementedException(); + var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); + + var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexerId); + + if (indexerMapping != null) + { + //Remove Indexer remotely and then remove the mapping + _radarrV3Proxy.RemoveIndexer(indexerMapping.RemoteIndexerId, Settings); + _appIndexerMapService.Delete(indexerMapping.Id); + } } public override void UpdateIndexer(IndexerDefinition indexer) diff --git a/src/NzbDrone.Core/Applications/Radarr/RadarrV3Proxy.cs b/src/NzbDrone.Core/Applications/Radarr/RadarrV3Proxy.cs index e65b4e4f5..54aef898d 100644 --- a/src/NzbDrone.Core/Applications/Radarr/RadarrV3Proxy.cs +++ b/src/NzbDrone.Core/Applications/Radarr/RadarrV3Proxy.cs @@ -14,6 +14,7 @@ namespace NzbDrone.Core.Applications.Radarr RadarrIndexer AddIndexer(RadarrIndexer indexer, RadarrSettings settings); List GetIndexers(RadarrSettings settings); List GetIndexerSchema(RadarrSettings settings); + void RemoveIndexer(int indexerId, RadarrSettings settings); ValidationFailure Test(RadarrSettings settings); } diff --git a/src/NzbDrone.Core/Applications/Readarr/Readarr.cs b/src/NzbDrone.Core/Applications/Readarr/Readarr.cs index 632d171de..a0bb490e5 100644 --- a/src/NzbDrone.Core/Applications/Readarr/Readarr.cs +++ b/src/NzbDrone.Core/Applications/Readarr/Readarr.cs @@ -47,8 +47,16 @@ namespace NzbDrone.Core.Applications.Readarr public override void RemoveIndexer(int indexerId) { - //Use the Id mapping here to delete the correct indexer - throw new System.NotImplementedException(); + var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); + + var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexerId); + + if (indexerMapping != null) + { + //Remove Indexer remotely and then remove the mapping + _readarrV1Proxy.RemoveIndexer(indexerMapping.RemoteIndexerId, Settings); + _appIndexerMapService.Delete(indexerMapping.Id); + } } public override void UpdateIndexer(IndexerDefinition indexer) diff --git a/src/NzbDrone.Core/Applications/Readarr/ReadarrV1Proxy.cs b/src/NzbDrone.Core/Applications/Readarr/ReadarrV1Proxy.cs index 71e6d08b3..f39c4f34b 100644 --- a/src/NzbDrone.Core/Applications/Readarr/ReadarrV1Proxy.cs +++ b/src/NzbDrone.Core/Applications/Readarr/ReadarrV1Proxy.cs @@ -14,6 +14,7 @@ namespace NzbDrone.Core.Applications.Readarr ReadarrIndexer AddIndexer(ReadarrIndexer indexer, ReadarrSettings settings); List GetIndexers(ReadarrSettings settings); List GetIndexerSchema(ReadarrSettings settings); + void RemoveIndexer(int indexerId, ReadarrSettings settings); ValidationFailure Test(ReadarrSettings settings); } diff --git a/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs b/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs index 6f5fd37d9..836c082cd 100644 --- a/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs +++ b/src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs @@ -47,8 +47,16 @@ namespace NzbDrone.Core.Applications.Sonarr public override void RemoveIndexer(int indexerId) { - //Use the Id mapping here to delete the correct indexer - throw new System.NotImplementedException(); + var appMappings = _appIndexerMapService.GetMappingsForApp(Definition.Id); + + var indexerMapping = appMappings.FirstOrDefault(m => m.IndexerId == indexerId); + + if (indexerMapping != null) + { + //Remove Indexer remotely and then remove the mapping + _sonarrV3Proxy.RemoveIndexer(indexerMapping.RemoteIndexerId, Settings); + _appIndexerMapService.Delete(indexerMapping.Id); + } } public override void UpdateIndexer(IndexerDefinition indexer) diff --git a/src/NzbDrone.Core/Applications/Sonarr/SonarrV3Proxy.cs b/src/NzbDrone.Core/Applications/Sonarr/SonarrV3Proxy.cs index 390d7ea7c..fd0731a63 100644 --- a/src/NzbDrone.Core/Applications/Sonarr/SonarrV3Proxy.cs +++ b/src/NzbDrone.Core/Applications/Sonarr/SonarrV3Proxy.cs @@ -14,6 +14,7 @@ namespace NzbDrone.Core.Applications.Sonarr SonarrIndexer AddIndexer(SonarrIndexer indexer, SonarrSettings settings); List GetIndexers(SonarrSettings settings); List GetIndexerSchema(SonarrSettings settings); + void RemoveIndexer(int indexerId, SonarrSettings settings); ValidationFailure Test(SonarrSettings settings); }