You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/src/NzbDrone.Core/Validation/Paths/MovieExistsValidator.cs

26 lines
691 B

using FluentValidation.Validators;
using NzbDrone.Core.Movies;
namespace NzbDrone.Core.Validation.Paths
{
public class MovieExistsValidator : PropertyValidator
{
private readonly IMovieService _movieService;
public MovieExistsValidator(IMovieService movieService)
: base("This movie has already been added")
{
_movieService = movieService;
}
protected override bool IsValid(PropertyValidatorContext context)
{
if (context.PropertyValue == null) return true;
int tmdbId = (int)context.PropertyValue;
return (_movieService.FindByTmdbId(tmdbId) == null);
}
}
}