New: Speed up API add by reworking AuthorExistsValidator

Co-authored-by: Qstick <qstick@gmail.com>
This commit is contained in:
Bogdan 2023-07-03 11:41:30 +03:00
parent 0e2d39f580
commit 09d44726a4

View file

@ -21,7 +21,9 @@ protected override bool IsValid(PropertyValidatorContext context)
return true;
}
return !_authorService.GetAllAuthors().Exists(s => s.Metadata.Value.ForeignAuthorId == context.PropertyValue.ToString());
var foreignAuthorId = context.PropertyValue.ToString();
return _authorService.FindById(foreignAuthorId) == null;
}
}
}