public virtual async Task <IHttpActionResult> GetSearchResults(GetQueryFacetsRequest request) { var queryString = HttpUtility.ParseQueryString(request.QueryString ?? ""); var SelectedFacets = SearchUrlProvider.BuildSelectedFacets(queryString).ToList(); var CurrentPage = int.TryParse(queryString[SearchRequestParams.Page], out int page) && page > 0 ? page : 1; var SortDirection = queryString[SearchRequestParams.SortDirection] ?? SearchRequestParams.DefaultSortDirection; var SortBy = queryString[SearchRequestParams.SortBy] ?? SearchRequestParams.DefaultSortBy; var BaseUrl = RequestUtils.GetBaseUrl(Request).ToString(); var searchCriteria = await BaseSearchCriteriaProvider.GetSearchCriteriaAsync(null, BaseUrl, true, CurrentPage).ConfigureAwait(false); searchCriteria.SortBy = SortBy; searchCriteria.SortDirection = SortDirection; searchCriteria.SelectedFacets.AddRange(SelectedFacets); var param = new GetSearchQueryViewModelParams { QueryName = request.QueryName, QueryType = request.QueryType, Scope = ComposerContext.Scope, CultureInfo = ComposerContext.CultureInfo, Criteria = searchCriteria, InventoryLocationIds = searchCriteria.InventoryLocationIds }; var viewModel = await SearchQueryViewService.GetSearchQueryViewModelAsync(param).ConfigureAwait(false); viewModel.ProductSearchResults.Facets = viewModel.ProductSearchResults.Facets.Where(f => !f.FieldName.StartsWith(SearchConfiguration.CategoryFacetFiledNamePrefix)).ToList(); return(Ok(viewModel)); }
public async Task <SearchQueryViewModel> GetTopSearchQueryViewModelAsync(SearchQueryType queryType, string queryName, int pageSize) { if (_topResultsViewModel != null && _topResultsViewModel.QueryName == queryName && _topResultsViewModel.QueryType == queryType) { return(_topResultsViewModel); } var criteria = BuildProductsSearchCriteria(); criteria.NumberOfItemsPerPage = pageSize; var param = new GetSearchQueryViewModelParams { QueryName = queryName, QueryType = queryType, Scope = ComposerContext.Scope, CultureInfo = ComposerContext.CultureInfo, Criteria = criteria, InventoryLocationIds = criteria.InventoryLocationIds }; _topResultsViewModel = await SearchQueryViewService.GetSearchQueryViewModelAsync(param).ConfigureAwait(false); if (_topResultsViewModel.ProductSearchResults.Pagination != null) { _topResultsViewModel.ProductSearchResults.Pagination.TotalNumberOfPages = 1; _topResultsViewModel.ProductSearchResults.Pagination.NextPage = null; } return(_topResultsViewModel); }
public virtual async Task <IHttpActionResult> GetFacets(GetQueryFacetsRequest request) { var queryString = HttpUtility.ParseQueryString(request.QueryString); var criteria = await BaseSearchCriteriaProvider.GetSearchCriteriaAsync(null, RequestUtils.GetBaseUrl(Request).ToString(), true).ConfigureAwait(false); criteria.NumberOfItemsPerPage = 0; criteria.SelectedFacets.AddRange(SearchUrlProvider.BuildSelectedFacets(queryString)); var param = new GetSearchQueryViewModelParams { QueryName = request.QueryName, QueryType = request.QueryType, Scope = ComposerContext.Scope, CultureInfo = ComposerContext.CultureInfo, Criteria = criteria, InventoryLocationIds = criteria.InventoryLocationIds }; var viewModel = await SearchQueryViewService.GetSearchQueryViewModelAsync(param).ConfigureAwait(false); viewModel.ProductSearchResults.Facets = viewModel.ProductSearchResults.Facets.Where(f => !f.FieldName.StartsWith(SearchConfiguration.CategoryFacetFiledNamePrefix)).ToList(); return(Ok(viewModel)); }
public async Task <SearchQueryViewModel> GetSearchQueryViewModelAsync(GetSearchQueryViewModelParams param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (ViewModel != null) { return(ViewModel); } param.Scope = ComposerContext.Scope; param.CultureInfo = ComposerContext.CultureInfo; ViewModel = await SearchQueryViewService.GetSearchQueryViewModelAsync(param).ConfigureAwait(false); return(ViewModel); }
public async Task <SearchQueryViewModel> GetSearchQueryViewModelAsync(SearchQueryType queryType, string queryName) { if (_viewModel != null && _viewModel.QueryName == queryName && _viewModel.QueryType == queryType) { return(_viewModel); } var criteria = BuildProductsSearchCriteria(); var param = new GetSearchQueryViewModelParams { QueryName = queryName, QueryType = queryType, Scope = ComposerContext.Scope, CultureInfo = ComposerContext.CultureInfo, Criteria = criteria, InventoryLocationIds = criteria.InventoryLocationIds }; _viewModel = await SearchQueryViewService.GetSearchQueryViewModelAsync(param).ConfigureAwait(false); return(_viewModel); }