Esempio n. 1
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);
        }
Esempio n. 2
0
        public StoreLiquidResult GetRelatedProductsPartialByBrand(Brand brand,
                                                                  List <Product> products,
                                                                  PageDesign pageDesign,
                                                                  List <ProductCategory> productCategories)
        {
            var result = new StoreLiquidResult();

            result.PageDesingName = pageDesign.Name;
            var dic = new Dictionary <String, String>();

            dic.Add(StoreConstants.PageOutput, "");
            try
            {
                var brandLiquid = new BrandLiquid(brand, ImageWidth, ImageHeight);

                var items = new List <ProductLiquid>();
                foreach (var item in products)
                {
                    var imageWidth  = GetSettingValueInt("BrandProduct_ImageWidth", 50);
                    var imageHeight = GetSettingValueInt("BrandProduct_ImageHeight", 50);
                    var cat         = productCategories.FirstOrDefault(r => r.Id == item.ProductCategoryId);
                    var product     = new ProductLiquid(item, cat, imageWidth, imageHeight);
                    product.Brand = brand;
                    items.Add(product);
                }

                object anonymousObject = new
                {
                    products = LiquidAnonymousObject.GetProductsLiquid(items),
                    brand    = LiquidAnonymousObject.GetBrandLiquid(brandLiquid)
                };

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


                dic[StoreConstants.PageOutput] = indexPageOutput;
                result.LiquidRenderedResult    = dic;

                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "GetRelatedProductsPartial");
                return(result);
            }
        }
Esempio n. 3
0
        public StoreLiquidResult GetRelatedProductsPartialByCategory(ProductCategory category,
                                                                     List <Product> products,
                                                                     PageDesign pageDesign
                                                                     )
        {
            var result = new StoreLiquidResult();

            result.PageDesingName = pageDesign.Name;
            var dic = new Dictionary <String, String>();

            try
            {
                var items = new List <ProductLiquid>();
                foreach (var item in products)
                {
                    var blog = new ProductLiquid(item, category, ImageWidth, ImageHeight);
                    items.Add(blog);
                }

                var indexPageOutput = LiquidEngineHelper.RenderPage(pageDesign, new
                {
                    products = LiquidAnonymousObject.GetProductsLiquid(items)
                }
                                                                    );


                dic[StoreConstants.PageOutput] = indexPageOutput;



                result.LiquidRenderedResult = dic;
                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "GetRelatedProductsPartial");
                return(result);
            }
        }
Esempio n. 4
0
        public StoreLiquidResult GetRetailerDetailPage(Retailer retailer, List <Product> products, PageDesign pageDesign, List <ProductCategory> productCategories)
        {
            var result = new StoreLiquidResult();
            var dic    = new Dictionary <String, String>();

            dic.Add(StoreConstants.PageOutput, "");

            try
            {
                var retailerLiquid = new RetailerLiquid(retailer, ImageWidth, ImageHeight);
                retailerLiquid.Products          = products;
                retailerLiquid.ProductCategories = productCategories;

                object anonymousObject = new
                {
                    retailer          = LiquidAnonymousObject.GetRetailer(retailerLiquid),
                    products          = LiquidAnonymousObject.GetProductsLiquid(retailerLiquid.ProductLiquidList),
                    productCategories = LiquidAnonymousObject.GetProductCategories(retailerLiquid.ProductCategoriesLiquids)
                };
                var indexPageOutput = LiquidEngineHelper.RenderPage(pageDesign, anonymousObject);


                dic[StoreConstants.PageOutput] = indexPageOutput;
                result.PageDesingName          = pageDesign.Name;
                result.DetailLink = retailerLiquid.DetailLink;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }



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

            return(result);
        }
Esempio n. 5
0
        public StoreLiquidResult GetPopularProducts(List <Product> products, List <ProductCategory> productCategories, PageDesign pageDesign)
        {
            var result = new StoreLiquidResult();
            var dic    = new Dictionary <String, String>();

            dic.Add(StoreConstants.PageOutput, "");
            try
            {
                var items = new List <ProductLiquid>();
                foreach (var item in products)
                {
                    var cat     = productCategories.FirstOrDefault(r => r.Id == item.ProductCategoryId);
                    var product = new ProductLiquid(item, cat, this.ImageWidth, this.ImageHeight);
                    items.Add(product);
                }

                object anonymousObject = new
                {
                    products = LiquidAnonymousObject.GetProductsLiquid(items)
                };

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


                dic[StoreConstants.PageOutput] = indexPageOutput;
                result.LiquidRenderedResult    = dic;

                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "GetPopularProducts");
                dic.Add(StoreConstants.PageOutput, ex.Message);
                return(result);
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public StoreLiquidResult GetHomePageDesign(PageDesign pageDesing, List <FileManager> sliderImages, List <Product> products, List <Content> blogs, List <Content> news,
                                                   List <Category> categories, List <ProductCategory> productCategories)
        {
            var result = new StoreLiquidResult();
            var dic    = new Dictionary <String, String>();

            dic.Add(StoreConstants.PageOutput, "");
            result.LiquidRenderedResult = dic;
            result.PageDesingName       = pageDesing.Name;
            try
            {
                if (pageDesing == null)
                {
                    throw new Exception("PageDesing is null");
                }


                var home = new HomePageLiquid(pageDesing, sliderImages);
                home.Products           = products;
                home.ImageWidthProduct  = GetSettingValueInt("ProductsHomePage_ImageWidth", 50);
                home.ImageHeightProduct = GetSettingValueInt("ProductsHomePage_ImageHeight", 50);

                home.Blogs           = blogs;
                home.ImageWidthBlog  = GetSettingValueInt("BlogsHomePage_ImageWidth", 50);
                home.ImageHeightBlog = GetSettingValueInt("BlogsHomePage_ImageHeight", 50);


                home.News            = news;
                home.ImageWidthNews  = GetSettingValueInt("NewsHomePage_ImageWidth", 50);
                home.ImageHeightNews = GetSettingValueInt("NewsHomePage_ImageHeight", 50);


                home.ImageWidthSlider  = GetSettingValueInt("SliderHomePage_ImageWidth", 500);
                home.ImageHeightSlider = GetSettingValueInt("SliderHomePage_ImageHeight", 500);


                home.Categories        = categories;
                home.ProductCategories = productCategories;

                object anonymousObject = new
                {
                    blogs             = LiquidAnonymousObject.GetContentLiquid(home.BlogsLiquidList),
                    products          = LiquidAnonymousObject.GetProductsLiquid(home.ProductLiquidList),
                    news              = LiquidAnonymousObject.GetContentLiquid(home.NewsLiquidList),
                    productCategories = LiquidAnonymousObject.GetProductCategories(home.ProductCategoriesLiquids),
                    categories        = LiquidAnonymousObject.GetCategoriesLiquid(home.CategoriesLiquids),
                    sliders           = LiquidAnonymousObject.GetSliderImagesLiquidList(home.SliderImagesLiquid),
                };


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

            return(result);
        }