Esempio n. 1
0
        public async Task <CategoryBrowsingViewModel> GetCategoryAvailableProductsAsync(GetBrowseCategoryParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }

            if (ViewModel != null)
            {
                return(ViewModel);
            }

            ViewModel = await CategoryBrowsingViewService.GetCategoryBrowsingViewModelAsync(new GetCategoryBrowsingViewModelParam
            {
                CategoryId           = param.CategoryId,
                CategoryName         = await GetCategoryNameAsync(param.CategoryId),
                BaseUrl              = RequestUtils.GetBaseUrl(param.Request).ToString(),
                IsAllProducts        = CategoryMetaContext.GetIsAllProductPage(),
                Page                 = param.Page,
                SortBy               = param.SortBy,
                SortDirection        = param.SortDirection,
                InventoryLocationIds = await InventoryLocationProvider.GetInventoryLocationIdsForSearchAsync(),
                SelectedFacets       = SearchUrlProvider.BuildSelectedFacets(param.Request.QueryString).ToList(),
                CultureInfo          = ComposerContext.CultureInfo,
            }).ConfigureAwait(false);

            return(ViewModel);
        }
Esempio n. 2
0
        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);
        }