public virtual FilterProductViewModel Build()
        {
            var        page       = _requestModelAccessor.RequestModel.CurrentPageModel;
            IViewModel viewData   = null;
            int        totalCount = 0;

            if (page.IsBrandPageType())
            {
                //Brand Page Type
                var model = _brandViewModelBuilder.Build(page);
                totalCount = model?.Pagination?.TotalCount ?? 0;
                viewData   = model;
            }
            else if (page.IsSearchResultPageType())
            {
                //Search Result Page Type
                var model = _searchResultViewModelBuilder.Build();
                totalCount = model?.Pagination?.TotalCount ?? 0;
                viewData   = model;
            }
            else if (page.IsProductListPageType())
            {
                //Product List Page Type
                var model = _productListViewModelBuilder.Build();
                totalCount = model?.Pagination?.TotalCount ?? 0;
                viewData   = model;
            }
            else
            {
                if (_routeRequestInfoAccessor.RouteRequestInfo?.Data is ProductPageData productData)
                {
                    var model = _categoryPageViewModelBuilder.Build(productData.CategorySystemId.Value);
                    totalCount = model?.Pagination?.TotalCount ?? 0;
                    viewData   = model;
                }
            }

            if (viewData != null)
            {
                return(new FilterProductViewModel()
                {
                    ViewData = viewData,
                    TotalCount = totalCount
                });
            }

            return(null);
        }
예제 #2
0
 public ActionResult Index()
 {
     return(View(_searchResultViewModelBuilder.Build()));
 }