Example #1
0
        public IActionResult SearchGet(string query, string orderBy = "relevance")
        {
            if (query == null)
            {
                return(View("../Admin/Search", new AdminSearchViewModel()));
            }

            var viewModel = new AdminSearchViewModel {
                SearchQuery = query, OrderBy = orderBy
            };

            if (string.IsNullOrWhiteSpace(query))
            {
                viewModel.Error = "Search query must not be empty";
            }
            else
            {
                bool orderByRelevance = orderBy == "relevance";
                AdminSearchResultsViewModel results = adminSearchService.Search(query, orderByRelevance);

                viewModel.SearchResults = results;
            }

            return(View("../Admin/Search", viewModel));
        }
        public IActionResult SearchGet(string query)
        {
            if (query == null)
            {
                return(View("../Admin/Search", new AdminSearchViewModel()));
            }

            var viewModel = new AdminSearchViewModel {
                SearchQuery = query
            };

            if (string.IsNullOrWhiteSpace(query))
            {
                viewModel.Error = "Search query must not be empty";
            }
            else
            {
                var results = adminSearchService.Search(query);

                viewModel.SearchResults = results;
            }

            return(View("../Admin/Search", viewModel));
        }