public async Task <CatalogSearchResult> SearchAsync(CatalogSearchCriteria criteria)
        {
            var retVal = new CatalogSearchResult();

            var workContext = _workContextFactory();

            var searchCriteria = new VirtoCommerceDomainCatalogModelSearchCriteria
            {
                StoreId                    = workContext.CurrentStore.Id,
                Keyword                    = criteria.Keyword,
                ResponseGroup              = criteria.ResponseGroup.ToString(),
                SearchInChildren           = criteria.SearchInChildren,
                CategoryId                 = criteria.CategoryId,
                CatalogId                  = criteria.CatalogId,
                Currency                   = workContext.CurrentCurrency.Code,
                HideDirectLinkedCategories = true,
                Terms        = criteria.Terms.ToStrings(),
                PricelistIds = workContext.CurrentPricelists.Where(p => p.Currency == workContext.CurrentCurrency.Code).Select(p => p.Id).ToList(),
                Skip         = criteria.Start,
                Take         = criteria.PageSize,
                Sort         = criteria.SortBy
            };

            var searchTask = _searchApi.SearchModuleSearchAsync(searchCriteria);

            if (criteria.CategoryId != null)
            {
                var category = await _catalogModuleApi.CatalogModuleCategoriesGetAsync(criteria.CategoryId);

                if (category != null)
                {
                    retVal.Category = category.ToWebModel(workContext.CurrentLanguage);
                }
            }
            var result = await searchTask;


            if (result != null)
            {
                if (result.Products != null && result.Products.Any())
                {
                    var products = result.Products.Select(x => x.ToWebModel(workContext.CurrentLanguage, workContext.CurrentCurrency)).ToArray();
                    retVal.Products = new StorefrontPagedList <Product>(products, criteria.PageNumber, criteria.PageSize, result.ProductsTotalCount.Value, page => workContext.RequestUrl.SetQueryParameter("page", page.ToString()).ToString());

                    await Task.WhenAll(_pricingService.EvaluateProductPricesAsync(retVal.Products), LoadProductsInventoriesAsync(retVal.Products));
                }

                if (result.Categories != null && result.Categories.Any())
                {
                    retVal.Categories = result.Categories.Select(x => x.ToWebModel(workContext.CurrentLanguage));
                }

                if (result.Aggregations != null)
                {
                    retVal.Aggregations = result.Aggregations.Select(x => x.ToWebModel()).ToArray();
                }
            }

            return(retVal);
        }
 public static VirtoCommerceDomainCatalogModelSearchCriteria ToServiceModel(this CatalogSearchCriteria criteria, WorkContext workContext)
 {
     var result = new VirtoCommerceDomainCatalogModelSearchCriteria
     {
         StoreId = workContext.CurrentStore.Id,
         Keyword = criteria.Keyword,
         ResponseGroup = criteria.ResponseGroup.ToString(),
         SearchInChildren = criteria.SearchInChildren,
         CategoryId = criteria.CategoryId,
         CatalogId = criteria.CatalogId,
         Currency = criteria.Currency == null ?  workContext.CurrentCurrency.Code : criteria.Currency.Code,
         HideDirectLinkedCategories = true,
         Terms = criteria.Terms.ToStrings(),
         PricelistIds = workContext.CurrentPricelists.Where(p => p.Currency == workContext.CurrentCurrency.Code).Select(p => p.Id).ToList(),
         Skip = criteria.Start,
         Take = criteria.PageSize,
         Sort = criteria.SortBy
     };
     return result;
 }
Пример #3
0
        public static VirtoCommerceDomainCatalogModelSearchCriteria ToServiceModel(this CatalogSearchCriteria criteria, WorkContext workContext)
        {
            var result = new VirtoCommerceDomainCatalogModelSearchCriteria
            {
                StoreId                    = workContext.CurrentStore.Id,
                Keyword                    = criteria.Keyword,
                ResponseGroup              = criteria.ResponseGroup.ToString(),
                SearchInChildren           = criteria.SearchInChildren,
                CategoryId                 = criteria.CategoryId,
                CatalogId                  = criteria.CatalogId,
                Currency                   = criteria.Currency == null ?  workContext.CurrentCurrency.Code : criteria.Currency.Code,
                HideDirectLinkedCategories = true,
                Terms        = criteria.Terms.ToStrings(),
                PricelistIds = workContext.CurrentPricelists.Where(p => p.Currency == workContext.CurrentCurrency.Code).Select(p => p.Id).ToList(),
                Skip         = criteria.Start,
                Take         = criteria.PageSize,
                Sort         = criteria.SortBy
            };

            return(result);
        }
Пример #4
0
        /// <summary>
        /// Search for products and categories 
        /// </summary>
        /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="criteria">Search parameters</param>
        /// <returns>Task of ApiResponse (VirtoCommerceCatalogModuleWebModelCatalogSearchResult)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<VirtoCommerceCatalogModuleWebModelCatalogSearchResult>> SearchModuleSearchAsyncWithHttpInfo (VirtoCommerceDomainCatalogModelSearchCriteria criteria)
        {
            // verify the required parameter 'criteria' is set
            if (criteria == null)
                throw new ApiException(400, "Missing required parameter 'criteria' when calling SearchModuleApi->SearchModuleSearch");

            var localVarPath = "/api/search";
            var localVarPathParams = new Dictionary<String, String>();
            var localVarQueryParams = new Dictionary<String, String>();
            var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var localVarFormParams = new Dictionary<String, String>();
            var localVarFileParams = new Dictionary<String, FileParameter>();
            Object localVarPostBody = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json", 
                "text/json", 
                "application/xml", 
                "text/xml", 
                "application/x-www-form-urlencoded"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json", 
                "text/json", 
                "application/xml", 
                "text/xml"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
            if (localVarHttpHeaderAccept != null)
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (criteria.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(criteria); // http body (model) parameter
            }
            else
            {
                localVarPostBody = criteria; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
                Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int) localVarResponse.StatusCode;

            if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404))
                throw new ApiException (localVarStatusCode, "Error calling SearchModuleSearch: " + localVarResponse.Content, localVarResponse.Content);
            else if (localVarStatusCode == 0)
                throw new ApiException (localVarStatusCode, "Error calling SearchModuleSearch: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);

            return new ApiResponse<VirtoCommerceCatalogModuleWebModelCatalogSearchResult>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (VirtoCommerceCatalogModuleWebModelCatalogSearchResult) Configuration.ApiClient.Deserialize(localVarResponse, typeof(VirtoCommerceCatalogModuleWebModelCatalogSearchResult)));
            
        }
Пример #5
0
        /// <summary>
        /// Search for products and categories 
        /// </summary>
        /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="criteria">Search parameters</param>
        /// <returns>Task of VirtoCommerceCatalogModuleWebModelCatalogSearchResult</returns>
        public async System.Threading.Tasks.Task<VirtoCommerceCatalogModuleWebModelCatalogSearchResult> SearchModuleSearchAsync (VirtoCommerceDomainCatalogModelSearchCriteria criteria)
        {
             ApiResponse<VirtoCommerceCatalogModuleWebModelCatalogSearchResult> localVarResponse = await SearchModuleSearchAsyncWithHttpInfo(criteria);
             return localVarResponse.Data;

        }
Пример #6
0
 /// <summary>
 /// Search for products and categories 
 /// </summary>
 /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="criteria">Search parameters</param>
 /// <returns>VirtoCommerceCatalogModuleWebModelCatalogSearchResult</returns>
 public VirtoCommerceCatalogModuleWebModelCatalogSearchResult SearchModuleSearch (VirtoCommerceDomainCatalogModelSearchCriteria criteria)
 {
      ApiResponse<VirtoCommerceCatalogModuleWebModelCatalogSearchResult> localVarResponse = SearchModuleSearchWithHttpInfo(criteria);
      return localVarResponse.Data;
 }
Пример #7
0
        /// <summary>
        /// Search for products and categories 
        /// </summary>
        /// <param name="criteria">Search parameters</param>
        /// <returns>Task of ApiResponse (VirtoCommerceCatalogModuleWebModelCatalogSearchResult)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<VirtoCommerceCatalogModuleWebModelCatalogSearchResult>> SearchModuleSearchAsyncWithHttpInfo (VirtoCommerceDomainCatalogModelSearchCriteria criteria)
        {
            // verify the required parameter 'criteria' is set
            if (criteria == null) throw new ApiException(400, "Missing required parameter 'criteria' when calling SearchModuleSearch");
            
    
            var path_ = "/api/search";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            // to determine the Accept header
            String[] http_header_accepts = new String[] {
                "application/json", "text/json"
            };
            String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
            if (http_header_accept != null)
                headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            
            
            
            
            postBody = Configuration.ApiClient.Serialize(criteria); // http body (model) parameter
            

            

            // make the HTTP request
            IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);

            int statusCode = (int) response.StatusCode;
 
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling SearchModuleSearch: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling SearchModuleSearch: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<VirtoCommerceCatalogModuleWebModelCatalogSearchResult>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (VirtoCommerceCatalogModuleWebModelCatalogSearchResult) Configuration.ApiClient.Deserialize(response, typeof(VirtoCommerceCatalogModuleWebModelCatalogSearchResult)));
            
        }
Пример #8
0
        /// <summary>
        /// Searches for the items by complex criteria. 
        /// </summary>
        /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="searchCriteria">The search criteria.</param>
        /// <returns>Task of VirtoCommerceCatalogModuleWebModelListEntrySearchResult</returns>
        public async System.Threading.Tasks.Task<VirtoCommerceCatalogModuleWebModelListEntrySearchResult> CatalogModuleListEntryListItemsSearchAsync (VirtoCommerceDomainCatalogModelSearchCriteria searchCriteria)
        {
             ApiResponse<VirtoCommerceCatalogModuleWebModelListEntrySearchResult> localVarResponse = await CatalogModuleListEntryListItemsSearchAsyncWithHttpInfo(searchCriteria);
             return localVarResponse.Data;

        }
Пример #9
0
 /// <summary>
 /// Searches for the items by complex criteria. 
 /// </summary>
 /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="searchCriteria">The search criteria.</param>
 /// <returns>VirtoCommerceCatalogModuleWebModelListEntrySearchResult</returns>
 public VirtoCommerceCatalogModuleWebModelListEntrySearchResult CatalogModuleListEntryListItemsSearch (VirtoCommerceDomainCatalogModelSearchCriteria searchCriteria)
 {
      ApiResponse<VirtoCommerceCatalogModuleWebModelListEntrySearchResult> localVarResponse = CatalogModuleListEntryListItemsSearchWithHttpInfo(searchCriteria);
      return localVarResponse.Data;
 }
        /// <summary>
        /// Search for products and categories
        /// </summary>
        /// <param name="criteria">Search parameters</param>
        /// <returns>Task of ApiResponse (VirtoCommerceCatalogModuleWebModelCatalogSearchResult)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <VirtoCommerceCatalogModuleWebModelCatalogSearchResult> > SearchModuleSearchAsyncWithHttpInfo(VirtoCommerceDomainCatalogModelSearchCriteria criteria)
        {
            // verify the required parameter 'criteria' is set
            if (criteria == null)
            {
                throw new ApiException(400, "Missing required parameter 'criteria' when calling SearchModuleSearch");
            }


            var path_ = "/api/search";

            var    pathParams   = new Dictionary <String, String>();
            var    queryParams  = new Dictionary <String, String>();
            var    headerParams = new Dictionary <String, String>();
            var    formParams   = new Dictionary <String, String>();
            var    fileParams   = new Dictionary <String, FileParameter>();
            String postBody     = null;

            // to determine the Accept header
            String[] http_header_accepts = new String[] {
                "application/json", "text/json"
            };
            String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);

            if (http_header_accept != null)
            {
                headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");



            postBody = Configuration.ApiClient.Serialize(criteria); // http body (model) parameter



            // make the HTTP request
            IRestResponse response = (IRestResponse)await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);

            int statusCode = (int)response.StatusCode;

            if (statusCode >= 400)
            {
                throw new ApiException(statusCode, "Error calling SearchModuleSearch: " + response.Content, response.Content);
            }
            else if (statusCode == 0)
            {
                throw new ApiException(statusCode, "Error calling SearchModuleSearch: " + response.ErrorMessage, response.ErrorMessage);
            }

            return(new ApiResponse <VirtoCommerceCatalogModuleWebModelCatalogSearchResult>(statusCode,
                                                                                           response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                                                           (VirtoCommerceCatalogModuleWebModelCatalogSearchResult)Configuration.ApiClient.Deserialize(response, typeof(VirtoCommerceCatalogModuleWebModelCatalogSearchResult))));
        }
        /// <summary>
        /// Search for products and categories
        /// </summary>
        /// <param name="criteria">Search parameters</param>
        /// <returns>Task of VirtoCommerceCatalogModuleWebModelCatalogSearchResult</returns>
        public async System.Threading.Tasks.Task <VirtoCommerceCatalogModuleWebModelCatalogSearchResult> SearchModuleSearchAsync(VirtoCommerceDomainCatalogModelSearchCriteria criteria)
        {
            ApiResponse <VirtoCommerceCatalogModuleWebModelCatalogSearchResult> response = await SearchModuleSearchAsyncWithHttpInfo(criteria);

            return(response.Data);
        }
        /// <summary>
        /// Search for products and categories
        /// </summary>
        /// <param name="criteria">Search parameters</param>
        /// <returns>VirtoCommerceCatalogModuleWebModelCatalogSearchResult</returns>
        public VirtoCommerceCatalogModuleWebModelCatalogSearchResult SearchModuleSearch(VirtoCommerceDomainCatalogModelSearchCriteria criteria)
        {
            ApiResponse <VirtoCommerceCatalogModuleWebModelCatalogSearchResult> response = SearchModuleSearchWithHttpInfo(criteria);

            return(response.Data);
        }
Пример #13
0
        /// <summary>
        /// Searches for the items by complex criteria 
        /// </summary>
        /// <param name="criteria">The search criteria.</param> 
        /// <returns>ApiResponse of VirtoCommerceCatalogModuleWebModelCatalogSearchResult</returns>
        public ApiResponse< VirtoCommerceCatalogModuleWebModelCatalogSearchResult > CatalogModuleSearchSearchWithHttpInfo (VirtoCommerceDomainCatalogModelSearchCriteria criteria)
        {
            
            // verify the required parameter 'criteria' is set
            if (criteria == null)
                throw new ApiException(400, "Missing required parameter 'criteria' when calling CatalogModuleApi->CatalogModuleSearchSearch");
            
    
            var path_ = "/api/catalog/search";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json", "text/json", "application/x-www-form-urlencoded"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/json", "text/json"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            
            
            
            
            if (criteria.GetType() != typeof(byte[]))
            {
                postBody = Configuration.ApiClient.Serialize(criteria); // http body (model) parameter
            }
            else
            {
                postBody = criteria; // byte array
            }

            
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, 
                Method.POST, queryParams, postBody, headerParams, formParams, fileParams,
                pathParams, httpContentType);

            int statusCode = (int) response.StatusCode;
    
            if (statusCode >= 400 && (statusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404))
                throw new ApiException (statusCode, "Error calling CatalogModuleSearchSearch: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling CatalogModuleSearchSearch: " + response.ErrorMessage, response.ErrorMessage);
    
            return new ApiResponse<VirtoCommerceCatalogModuleWebModelCatalogSearchResult>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (VirtoCommerceCatalogModuleWebModelCatalogSearchResult) Configuration.ApiClient.Deserialize(response, typeof(VirtoCommerceCatalogModuleWebModelCatalogSearchResult)));
            
        }
Пример #14
0
        /// <summary>
        /// Search for products and categories
        /// </summary>
        /// <exception cref="VirtoCommerce.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="criteria">Search parameters</param>
        /// <returns>Task of ApiResponse (VirtoCommerceCatalogModuleWebModelCatalogSearchResult)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <VirtoCommerceCatalogModuleWebModelCatalogSearchResult> > SearchModuleSearchAsyncWithHttpInfo(VirtoCommerceDomainCatalogModelSearchCriteria criteria)
        {
            // verify the required parameter 'criteria' is set
            if (criteria == null)
            {
                throw new ApiException(400, "Missing required parameter 'criteria' when calling SearchModuleApi->SearchModuleSearch");
            }

            var    localVarPath         = "/api/search";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json",
                "text/json",
                "application/xml",
                "text/xml",
                "application/x-www-form-urlencoded"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json",
                "text/json",
                "application/xml",
                "text/xml"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (criteria.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(criteria); // http body (model) parameter
            }
            else
            {
                localVarPostBody = criteria; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404))
            {
                throw new ApiException(localVarStatusCode, "Error calling SearchModuleSearch: " + localVarResponse.Content, localVarResponse.Content);
            }
            else if (localVarStatusCode == 0)
            {
                throw new ApiException(localVarStatusCode, "Error calling SearchModuleSearch: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
            }

            return(new ApiResponse <VirtoCommerceCatalogModuleWebModelCatalogSearchResult>(localVarStatusCode,
                                                                                           localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                                                           (VirtoCommerceCatalogModuleWebModelCatalogSearchResult)Configuration.ApiClient.Deserialize(localVarResponse, typeof(VirtoCommerceCatalogModuleWebModelCatalogSearchResult))));
        }
Пример #15
0
        /// <summary>
        /// Search for products and categories
        /// </summary>
        /// <param name="criteria">Search parameters</param>
        /// <returns>ApiResponse of VirtoCommerceCatalogModuleWebModelCatalogSearchResult</returns>
        public ApiResponse <VirtoCommerceCatalogModuleWebModelCatalogSearchResult> SearchModuleSearchWithHttpInfo(VirtoCommerceDomainCatalogModelSearchCriteria criteria)
        {
            // verify the required parameter 'criteria' is set
            if (criteria == null)
            {
                throw new ApiException(400, "Missing required parameter 'criteria' when calling SearchModuleApi->SearchModuleSearch");
            }


            var path_ = "/api/search";

            var    pathParams   = new Dictionary <String, String>();
            var    queryParams  = new Dictionary <String, String>();
            var    headerParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    formParams   = new Dictionary <String, String>();
            var    fileParams   = new Dictionary <String, FileParameter>();
            Object postBody     = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json", "text/json", "application/x-www-form-urlencoded"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/json", "text/json"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);

            if (httpHeaderAccept != null)
            {
                headerParams.Add("Accept", httpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");



            if (criteria.GetType() != typeof(byte[]))
            {
                postBody = Configuration.ApiClient.Serialize(criteria); // http body (model) parameter
            }
            else
            {
                postBody = criteria; // byte array
            }



            // make the HTTP request
            IRestResponse response = (IRestResponse)Configuration.ApiClient.CallApi(path_,
                                                                                    Method.POST, queryParams, postBody, headerParams, formParams, fileParams,
                                                                                    pathParams, httpContentType);

            int statusCode = (int)response.StatusCode;

            if (statusCode >= 400)
            {
                throw new ApiException(statusCode, "Error calling SearchModuleSearch: " + response.Content, response.Content);
            }
            else if (statusCode == 0)
            {
                throw new ApiException(statusCode, "Error calling SearchModuleSearch: " + response.ErrorMessage, response.ErrorMessage);
            }

            return(new ApiResponse <VirtoCommerceCatalogModuleWebModelCatalogSearchResult>(statusCode,
                                                                                           response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                                                           (VirtoCommerceCatalogModuleWebModelCatalogSearchResult)Configuration.ApiClient.Deserialize(response, typeof(VirtoCommerceCatalogModuleWebModelCatalogSearchResult))));
        }