public async Task <IEnumerable <dynamic> > GetAsync(string keywords) { var searchEngines = await _lookupRepository.ListAsync(); // Get the list of search engines from DB var response = new List <dynamic>(); if (searchEngines.Any()) { _logger.LogInformation($"Search Started"); searchEngines.ToList().ForEach(x => { _logger.LogInformation($"Loop through the search engine = {x.Name}"); try { var sites = new List <string>(); for (var page = 1; page < _config.MaxPages + 1; page++) { _logger.LogInformation($"Search Engine = {x.Name} and Page = {page}"); var urls = _util.GetUrls(x.Name, page, _config.SearchPage); sites.AddRange(urls); } if (sites.Any()) { var filteredUrls = _util.GetFilteredUrls(sites, _config.SiteName); if (filteredUrls.Any()) { dynamic result = new ExpandoObject(); result.SearchEngine = x.Name; result.RankingOrder = string.Join(", ", filteredUrls); response.Add(result); } } } catch (Exception ex) { _logger.LogError($"{nameof(SearchService)} {nameof(GetAsync)} {ex.Message}"); } }); _logger.LogInformation($"Search Completed"); } return(response); }