Exemple #1
0
        public static SearchResponse Create <T>(
            CommerceSearchOptions searchOptions,
            SearchResults <T> searchResults,
            Func <T, Item> getItemDelegate)
        {
            var connectResponse = ConnectSearchResponse.Create(searchOptions.ConnectSearchOptions, searchResults, getItemDelegate);
            var responseFacets  = connectResponse.Facets.Select(CommerceQueryFacet.Wrap).ToList();

            if (searchResults.Facets != null)
            {
                var searchFacets = new List <ConnectQueryFacet>();

                foreach (var foundCategory in searchResults.Facets.Categories)
                {
                    foreach (var responseFacet in responseFacets)
                    {
                        if (responseFacet.Name.Equals(foundCategory.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            responseFacet.FoundValues = foundCategory.Values;
                        }
                    }

                    foreach (var searchFacet in searchOptions.ConnectSearchOptions.FacetFields)
                    {
                        if (searchFacet.Name.Equals(foundCategory.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            searchFacet.FoundValues = new List <ConnectFacetValue>(foundCategory.Values);
                        }

                        searchFacets.Add(searchFacet);
                    }
                }

                searchOptions.ConnectSearchOptions.FacetFields = searchFacets;
            }

            var response = new SearchResponse(connectResponse)
            {
                Facets = responseFacets
            };

            return(response);
        }
Exemple #2
0
 /// <summary>
 /// Creates new instance of <see cref="SearchResponse"/>.
 /// </summary>
 internal SearchResponse(ConnectSearchResponse searchResponse)
 {
     _searchResponse = searchResponse;
 }
Exemple #3
0
 /// <summary>
 /// Creates new instance of <see cref="SearchResponse"/>.
 /// </summary>
 public SearchResponse()
 {
     _searchResponse = new ConnectSearchResponse();
 }