/// <inheritdoc /> public async IAsyncEnumerable <BasicInfo> GetResponse(string entityName, bool outputResults) { OmdbMovieInfo?response = await _omdbClient.TryGetItemByTitleAsync(entityName); if (response is null) { string message = $"{entityName} was not processed."; _logger.Warn(message); GlobalMessageHandler.OutputMessage(message); yield break; } // Get first search result from response and ignore all the rest. if (outputResults) { GlobalMessageHandler.OutputMessage($"Got {response.Title} from \"{Tag}\"."); } if (_searchResults.Add(response)) { yield return(response); } yield break; }
/// <inheritdoc /> public IReadOnlyList <BasicInfo> GetResponse(IReadOnlyList <string> entities, bool outputResults) { // Use HashSet to avoid duplicated data which can produce errors in further work. var searchResults = new HashSet <BasicInfo>(); foreach (string movie in entities) { OmdbMovieInfo?response = _omdbClient.TryGetItemByTitleAsync(movie).Result; if (response is null) { string message = $"{movie} was not processed."; _logger.Warn(message); GlobalMessageHandler.OutputMessage(message); continue; } // Get first search result from response and ignore all the rest. if (outputResults) { GlobalMessageHandler.OutputMessage($"Got {response.Title} from \"{Tag}\"."); } searchResults.Add(response); } return(searchResults.ToList()); }