Exemple #1
0
        public List <string> ExecuteSearch()
        {
            List <string> results = new List <string>();

            if (!HasKeywords())
            {
                Console.WriteLine("There are no keywords to execute the search");
                return(results);
            }

            foreach (var keyword in keywords)
            {
                SearchFightFactory factory      = new SearchFightFactory();
                string             searchResult = $"{keyword}:";

                foreach (SearchEngineEnum searchEngineEnum in Enum.GetValues(typeof(SearchEngineEnum)))
                {
                    ISearchEngine searchEngine = factory.CreateSearchFight(webRequest, searchEngineEnum);
                    double        quantity     = searchEngine.GetSearchResults(keyword);

                    searchResult = $"{searchResult} {searchEngineEnum}: {quantity}";

                    reports.Add(new Report()
                    {
                        SearchEngine = searchEngineEnum.ToString(), Keyword = keyword, Quantity = quantity
                    });
                }
                results.Add(searchResult);
            }
            return(results);
        }
Exemple #2
0
 public ActionResult Search(SearchInput sr)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var response = _iSeacrhEngine.GetSearchResults(sr);
             return(View("SearchOutput", response));
         }
         catch (Exception)
         {
             return(View("Error"));
         }
     }
     return(View("Search", sr));
 }