public StoreLiquidResult GetCategoryPage(PageDesign pageDesign, ProductCategory category)
        {
            var dic = new Dictionary <String, String>();

            dic.Add(StoreConstants.PageOutput, "");
            try
            {
                var productCategories = new ProductCategoryLiquid(category);



                object anonymousObject = new
                {
                    category = LiquidAnonymousObject.GetProductCategory(productCategories)
                };

                var indexPageOutput = LiquidEngineHelper.RenderPage(pageDesign, anonymousObject);
                dic[StoreConstants.PageOutput] = indexPageOutput;
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "GetProductCategoriesPartial");
            }

            var result = new StoreLiquidResult();

            result.LiquidRenderedResult = dic;
            result.PageDesingName       = pageDesign.Name;
            return(result);
        }
Exemplo n.º 2
0
        public static object GetProductCategory(ProductCategoryLiquid productCategories)
        {
            object anonymousObject = new
            {
                CategoryId    = productCategories.ProductCategory.Id,
                Name          = productCategories.ProductCategory.Name,
                ApiCategoryId = productCategories.ProductCategory.ApiCategoryId,
                Description   = productCategories.ProductCategory.Description
            };

            return(anonymousObject);
        }
Exemplo n.º 3
0
        public StoreLiquidResult GetProductsIndexPage(StorePagedList <Product> products,
                                                      PageDesign pageDesign, List <ProductCategory> categories)
        {
            var items = new List <ProductLiquid>();
            var cats  = new List <ProductCategoryLiquid>();

            foreach (var item in products.items)
            {
                var category = categories.FirstOrDefault(r => r.Id == item.ProductCategoryId);
                if (category != null)
                {
                    var blog = new ProductLiquid(item, category, ImageWidth, ImageHeight);
                    items.Add(blog);
                }
            }
            foreach (var category in categories)
            {
                var catLiquid = new ProductCategoryLiquid(category);
                catLiquid.Count = products.items.Count(r => r.ProductCategoryId == category.Id);
                cats.Add(catLiquid);
            }

            object anonymousObject = new
            {
                products   = LiquidAnonymousObject.GetProductsLiquid(items),
                categories = LiquidAnonymousObject.GetProductCategories(cats)
            };

            var indexPageOutput = LiquidEngineHelper.RenderPage(pageDesign, anonymousObject);


            var dic = new Dictionary <String, String>();

            dic.Add(StoreConstants.PageOutput, indexPageOutput);
            dic.Add(StoreConstants.PageSize, products.pageSize.ToStr());
            dic.Add(StoreConstants.PageNumber, products.page.ToStr());
            dic.Add(StoreConstants.TotalItemCount, products.totalItemCount.ToStr());



            var result = new StoreLiquidResult();

            result.PageDesingName       = pageDesign.Name;
            result.LiquidRenderedResult = dic;

            return(result);
        }
Exemplo n.º 4
0
        public StoreLiquidResult GetProductsSearchPage(Controller controller,
                                                       ProductsSearchResult productSearchResult,
                                                       PageDesign pageDesign,
                                                       List <ProductCategory> categories,
                                                       String search,
                                                       String filters,
                                                       String headerText,
                                                       String categoryApiId)
        {
            var dic = new Dictionary <String, String>();

            dic.Add(StoreConstants.PageOutput, "");
            var items              = new List <ProductLiquid>();
            var cats               = new List <ProductCategoryLiquid>();
            var products           = productSearchResult.Products;
            var filterGroups       = productSearchResult.FiltersGroups;
            var httpContextRequest = controller.Request;

            foreach (FilterGroup filterGroup in filterGroups)
            {
                foreach (Data.HelpersModel.Filter filter in filterGroup.FiltersHidden)
                {
                    if (string.IsNullOrEmpty(filter.Text))
                    {
                        continue;
                    }

                    filter.FilterLink = filter.Link(httpContextRequest);
                }
            }

            var filtersList = FilterHelper.GetFiltersFromContextRequest(httpContextRequest);

            foreach (var filter in filtersList)
            {
                filter.FilterLink = filter.LinkExclude(httpContextRequest, productSearchResult.Stats.OwnerType);
            }

            foreach (var item in products)
            {
                var category = categories.FirstOrDefault(r => r.Id == item.ProductCategoryId);
                if (category != null)
                {
                    var blog = new ProductLiquid(item, category, ImageWidth, ImageHeight);
                    items.Add(blog);
                }
            }

            var selectedCategory = categories.FirstOrDefault(r => r.ApiCategoryId.Equals(categoryApiId, StringComparison.InvariantCultureIgnoreCase));
            ProductCategoryLiquid selectedCategoryLiquid = null;

            if (selectedCategory == null)
            {
                selectedCategory = categories.FirstOrDefault();
            }
            selectedCategoryLiquid = new ProductCategoryLiquid(selectedCategory);


            var categoryTree = controller.RenderPartialToStringCache(
                "pCreateCategoryTree",
                new ViewDataDictionary(categories));



            object anonymousObject = new
            {
                filterExcluded   = LiquidAnonymousObject.GetFilters(filtersList),
                filterGroup      = LiquidAnonymousObject.GetFilterGroup(filterGroups),
                products         = LiquidAnonymousObject.GetProductsLiquid(items),
                selectedCategory = LiquidAnonymousObject.GetProductCategory(selectedCategoryLiquid),
                categoryTree     = categoryTree,
                search           = search,
                filters          = filters,
                headerText       = headerText,
                recordsTotal     = productSearchResult.Stats.RecordsTotal,
                isCleanButton    = !String.IsNullOrEmpty(search) || !String.IsNullOrEmpty(filters)
            };

            var indexPageOutput = LiquidEngineHelper.RenderPage(pageDesign, anonymousObject);

            dic[StoreConstants.PageOutput] = indexPageOutput;
            dic.Add(StoreConstants.PageSize, productSearchResult.PageSize.ToStr());
            dic.Add(StoreConstants.PageNumber, productSearchResult.Stats.PageCurrent.ToStr());
            dic.Add(StoreConstants.TotalItemCount, productSearchResult.Stats.RecordsTotal.ToStr());

            var result = new StoreLiquidResult();

            result.PageDesingName       = pageDesign.Name;
            result.LiquidRenderedResult = dic;
            if (selectedCategory != null)
            {
                result.PageTitle = selectedCategory.Name + " Products";
            }
            else
            {
                result.PageTitle = "Products";
            }
            return(result);
        }