public virtual async Task <CategoryBrowsingViewModel> GetViewModelAsync() { if (_viewModel != null) { return(_viewModel); } var categoryId = CategoryMetaContext.GetCategoryId(); _viewModel = await CategoryBrowsingViewService.GetCategoryBrowsingViewModelAsync(new GetCategoryBrowsingViewModelParam { CategoryId = categoryId, CategoryName = await GetCategoryNameAsync(categoryId).ConfigureAwait(false), BaseUrl = RequestUtils.GetBaseUrl(Request).ToString(), IsAllProducts = CategoryMetaContext.GetIsAllProductPage(), NumberOfItemsPerPage = SearchConfiguration.MaxItemsPerPage, Page = CurrentPage, SortBy = SortBy, SortDirection = SortDirection, InventoryLocationIds = await InventoryLocationProvider.GetInventoryLocationIdsForSearchAsync().ConfigureAwait(false), SelectedFacets = SearchUrlProvider.BuildSelectedFacets(Request.QueryString).ToList(), CultureInfo = ComposerContext.CultureInfo, }).ConfigureAwait(false); return(_viewModel); }
protected ActionResult ExecuteBrowsing(string emptyView, string filledView, Func <CategoryBrowsingViewModel, object> viewModelSelector, object emptyViewModel, int page, string sortBy = null, string sortDirection = null) { var categoryId = CategoryMetaContext.GetCategoryId(); if (string.IsNullOrWhiteSpace(categoryId)) { return(View(emptyView, emptyViewModel)); } var container = RequestContext.GetCategoryAvailableProductsAsync(new GetBrowseCategoryParam { Request = Request, Page = page, SortBy = sortBy, SortDirection = sortDirection, CategoryId = categoryId, }).Result; var viewName = container.ProductSearchResults.TotalCount <= 0 ? emptyView : filledView; var model = viewModelSelector.Invoke(container); if (model is CategoryBrowsingViewModel) { ExtendSpecificViewsWithContext(filledView, (CategoryBrowsingViewModel)model); } return(View(viewName, model)); }