Fixed: Error when adding an already excluded movie to the exclusion list.

Fixes #2462
pull/2196/merge
Leonardo Galli 7 years ago
parent eb1c3c8b82
commit aab14d02f9

@ -15,6 +15,7 @@ namespace NzbDrone.Core.NetImport.ImportExclusions
public interface IImportExclusionsRepository : IBasicRepository<ImportExclusion> public interface IImportExclusionsRepository : IBasicRepository<ImportExclusion>
{ {
bool IsMovieExcluded(int tmdbid); bool IsMovieExcluded(int tmdbid);
ImportExclusion GetByTmdbid(int tmdbid);
} }
public class ImportExclusionsRepository : BasicRepository<ImportExclusion>, IImportExclusionsRepository public class ImportExclusionsRepository : BasicRepository<ImportExclusion>, IImportExclusionsRepository
@ -31,5 +32,10 @@ namespace NzbDrone.Core.NetImport.ImportExclusions
{ {
return Query.Where(ex => ex.TmdbId == tmdbid).Any(); return Query.Where(ex => ex.TmdbId == tmdbid).Any();
} }
public ImportExclusion GetByTmdbid(int tmdbid)
{
return Query.Where(ex => ex.TmdbId == tmdbid).First();
}
} }
} }

@ -47,6 +47,10 @@ namespace NzbDrone.Core.NetImport.ImportExclusions
public ImportExclusion AddExclusion(ImportExclusion exclusion) public ImportExclusion AddExclusion(ImportExclusion exclusion)
{ {
if (_exclusionRepository.IsMovieExcluded(exclusion.TmdbId))
{
return _exclusionRepository.GetByTmdbid(exclusion.TmdbId);
}
return _exclusionRepository.Insert(exclusion); return _exclusionRepository.Insert(exclusion);
} }

Loading…
Cancel
Save