public PerformSearchEngineCommandHandler(
     BlackdotTechTestContext blackdotTechTestContext,
     ILogger <PerformSearchEngineCommandHandler> logger,
     SearchEngineQueryBuilder builder,
     ISearchEngineService searchEngineService,
     SearchEngineQueryResultBuilder searchEngineQueryResultBuilder)
 {
     _blackdotTechTestContext = blackdotTechTestContext;
     _logger = logger;
     _searchEngineQueryBuilder       = builder;
     _searchEngineService            = searchEngineService;
     _searchEngineQueryResultBuilder = searchEngineQueryResultBuilder;
 }
        public SearchEngineQuery UpdateSearchResults(SearchEngineQueryResultBuilder searchEngineQueryResultBuilder,
                                                     IEnumerable <SearchEngineQueryResultBuilderParameters> results)
        {
            if (QueryResults == null)
            {
                throw new InvalidOperationException("QueryResults must be loaded before adding");
            }

            QueryResults = new List <SearchEngineQueryResult>();
            foreach (var result in results)
            {
                result.RelatedQueryId = Id;
                QueryResults.Add(searchEngineQueryResultBuilder.Build(result));
            }

            return(EnsureValid());
        }