private async Task ValidateIsUniqueAsync(AddPageDirectoryCommand command, IExecutionContext executionContext) { var query = new IsPageDirectoryPathUniqueQuery(); query.ParentPageDirectoryId = command.ParentPageDirectoryId; query.UrlPath = command.UrlPath; var isUnique = await _queryExecutor.ExecuteAsync(query, executionContext); if (!isUnique) { var message = $"A page directory already exists in that parent directory with the path '{command.UrlPath}'"; throw new UniqueConstraintViolationException(message, "UrlPath", command.UrlPath); } }
public IDomainRepositoryQueryContext <bool> IsPathUnique(IsPageDirectoryPathUniqueQuery query) { return(DomainRepositoryQueryContextFactory.Create(query, ExtendableContentRepository)); }