public JsonResult GetProductsByAjax( JsonProductSearchRequest jsonProductSearchRequest) { GetProductsByCategoryRequest productSearchRequest = GenerateProductSearchRequestFrom(jsonProductSearchRequest); GetProductsByCategoryResponse response = _productService.GetProductsByCategory(productSearchRequest); ProductSearchResultView productSearchResultView = GetProductSearchResultViewFrom(response); return Json(productSearchResultView); }
private static GetProductsByCategoryRequest GenerateProductSearchRequestFrom( JsonProductSearchRequest jsonProductSearchRequest) { GetProductsByCategoryRequest productSearchRequest = new GetProductsByCategoryRequest(); productSearchRequest.NumberOfResultsPerPage = int.Parse(ApplicationSettingsFactory .GetApplicationSettings().NumberOfResultsPerPage); productSearchRequest.Index = jsonProductSearchRequest.Index; productSearchRequest.CategoryId = jsonProductSearchRequest.CategoryId; productSearchRequest.SortBy = jsonProductSearchRequest.SortBy; List<RefinementGroup> refinementGroups = new List<RefinementGroup>(); RefinementGroup refinementGroup; foreach (JsonRefinementGroup jsonRefinementGroup in jsonProductSearchRequest.RefinementGroups) { switch ((RefinementGroupings)jsonRefinementGroup.GroupId) { case RefinementGroupings.brand: productSearchRequest.BrandIds = jsonRefinementGroup.SelectedRefinements; break; case RefinementGroupings.color: productSearchRequest.ColorIds = jsonRefinementGroup.SelectedRefinements; break; case RefinementGroupings.size: productSearchRequest.SizeIds = jsonRefinementGroup.SelectedRefinements; break; default: break; } } return productSearchRequest; }