Example #1
0
        private static GetProductsByCategoryRequest GenerateProductSearchRequestFrom(
            DTOs.ProductSearchRequest productSearchRequest)
        {
            var request = new GetProductsByCategoryRequest();

            request.NumberOfResultsPerPage = int.Parse(ApplicationSettingsFactory
                                                       .GetApplicationSettings().NumberOfResultsPerPage);
            request.Index      = productSearchRequest.Index;
            request.CategoryId = productSearchRequest.CategoryId;
            request.SortBy     = productSearchRequest.SortBy;

            var refinementGroups = new List <RefinementGroup>();

            foreach (var refinementGroup in productSearchRequest.RefinementGroups)
            {
                switch ((RefinementGroupings)refinementGroup.GroupId)
                {
                case RefinementGroupings.brand:
                    request.BrandIds = refinementGroup.SelectedRefinements;
                    break;

                case RefinementGroupings.color:
                    request.ColorIds = refinementGroup.SelectedRefinements;
                    break;

                case RefinementGroupings.size:
                    request.SizeIds = refinementGroup.SelectedRefinements;
                    break;

                default:
                    break;
                }
            }
            return(request);
        }
Example #2
0
        public ProductSearchResultView GetProductsByAjax(
            DTOs.ProductSearchRequest productSearchRequest)
        {
            var request  = GenerateProductSearchRequestFrom(productSearchRequest);
            var response = _productService.GetProductsByCategory(request);
            var productSearchResultView = GetProductSearchResultViewFrom(response);

            return(productSearchResultView);
        }