From aab14d02f953c19e06457adb2d72da9dcf06c6e8 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Wed, 31 Jan 2018 15:03:29 +0100 Subject: [PATCH] Fixed: Error when adding an already excluded movie to the exclusion list. Fixes #2462 --- .../ImportExclusions/ImportExclusionsRepository.cs | 6 ++++++ .../NetImport/ImportExclusions/ImportExclusionsService.cs | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsRepository.cs b/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsRepository.cs index 35689b679..7846cb0f3 100644 --- a/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsRepository.cs +++ b/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsRepository.cs @@ -15,6 +15,7 @@ namespace NzbDrone.Core.NetImport.ImportExclusions public interface IImportExclusionsRepository : IBasicRepository { bool IsMovieExcluded(int tmdbid); + ImportExclusion GetByTmdbid(int tmdbid); } public class ImportExclusionsRepository : BasicRepository, IImportExclusionsRepository @@ -31,5 +32,10 @@ namespace NzbDrone.Core.NetImport.ImportExclusions { return Query.Where(ex => ex.TmdbId == tmdbid).Any(); } + + public ImportExclusion GetByTmdbid(int tmdbid) + { + return Query.Where(ex => ex.TmdbId == tmdbid).First(); + } } } diff --git a/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsService.cs b/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsService.cs index 34ff8125d..db289f344 100644 --- a/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsService.cs +++ b/src/NzbDrone.Core/NetImport/ImportExclusions/ImportExclusionsService.cs @@ -47,6 +47,10 @@ namespace NzbDrone.Core.NetImport.ImportExclusions public ImportExclusion AddExclusion(ImportExclusion exclusion) { + if (_exclusionRepository.IsMovieExcluded(exclusion.TmdbId)) + { + return _exclusionRepository.GetByTmdbid(exclusion.TmdbId); + } return _exclusionRepository.Insert(exclusion); }