Ejemplo n.º 1
0
        private async Task <IEnumerable <SearchResult> > Search(string query)
        {
            IsExecuting = true;
            var results = await Task.Factory.StartNew(() => searchService.Search(query));

            IsExecuting = false;
            return(results);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> WebSearch(string query)
        {
            var model = new SearchResultVM {
                Query = query
            };

            if (string.IsNullOrWhiteSpace(query))
            {
                model.Query = null;
                model.AddMessage("Error: query is empty!");
            }
            else
            {
                model = await webSearchService.Search(query);

                if (model.Items?.Any() == true)
                {
                    await repository.Add(model);
                }
            }

            return(View("Index", model));
        }