public virtual async Task <FilterProductViewModel> BuildAsync()
        {
            var        page       = _requestModelAccessor.RequestModel.CurrentPageModel;
            IViewModel viewData   = null;
            int        totalCount = 0;

            if (page.IsBrandPageType())
            {
                //Brand Page Type
                var model = await _brandViewModelBuilder.BuildAsync(page);

                totalCount = model?.Pagination?.TotalCount ?? 0;
                viewData   = model;
            }
            else if (page.IsSearchResultPageType())
            {
                //Search Result Page Type
                var model = await _searchResultViewModelBuilder.BuildAsync();

                totalCount = model?.Pagination?.TotalCount ?? 0;
                viewData   = model;
            }
            else if (page.IsProductListPageType())
            {
                //Product List Page Type
                var model = await _productListViewModelBuilder.BuildAsync();

                totalCount = model?.Pagination?.TotalCount ?? 0;
                viewData   = model;
            }
            else
            {
                if (_routeRequestInfoAccessor.RouteRequestInfo?.Data is ProductPageData productData)
                {
                    var model = await _categoryPageViewModelBuilder.BuildAsync(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 async Task <ActionResult> Index(PageModel currentPageModel)
        {
            var model = await _brandViewModelBuilder.BuildAsync(currentPageModel);

            return(View(model));
        }