Exemple #1
0
        public StoreLiquidResult GetContentsIndexPage(
            StorePagedList <Content> contents,
            PageDesign pageDesign,
            List <Category> categories, String type)
        {
            var items = new List <ContentLiquid>();
            var cats  = new List <CategoryLiquid>();

            foreach (var item in contents.items)
            {
                var category = categories.FirstOrDefault(r => r.Id == item.CategoryId);
                if (category != null)
                {
                    var blog = new ContentLiquid(item, category, type, ImageWidth, ImageHeight);
                    items.Add(blog);
                }
            }
            foreach (var category in categories)
            {
                var catLiquid = new CategoryLiquid(category, type);
                catLiquid.Count = contents.items.Count(r => r.CategoryId == category.Id);
                cats.Add(catLiquid);
            }

            var indexPageOutput = LiquidEngineHelper.RenderPage(pageDesign, new
            {
                items      = LiquidAnonymousObject.GetContentLiquid(items),
                categories = LiquidAnonymousObject.GetCategoriesLiquid(cats)
            }
                                                                );


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

            dic.Add(StoreConstants.PageOutput, indexPageOutput);
            dic.Add(StoreConstants.PageSize, contents.pageSize.ToStr());
            dic.Add(StoreConstants.PageNumber, contents.page.ToStr());
            dic.Add(StoreConstants.TotalItemCount, contents.totalItemCount.ToStr());
            //dic.Add(StoreConstants.IsPagingUp, pageDesign.IsPagingUp ? Boolean.TrueString : Boolean.FalseString);
            //dic.Add(StoreConstants.IsPagingDown, pageDesign.IsPagingDown ? Boolean.TrueString : Boolean.FalseString);

            var result = new StoreLiquidResult();

            result.LiquidRenderedResult = dic;
            result.PageDesingName       = pageDesign.Name;
            return(result);
        }
        public StoreLiquidResult GetCategoriesIndexPage(PageDesign pageDesign, StorePagedList <Category> categories, string type)
        {
            var result = new StoreLiquidResult();

            try
            {
                var cats = new List <CategoryLiquid>();
                foreach (var item in categories.items)
                {
                    cats.Add(new CategoryLiquid(item, type));
                }

                object anonymousObject = new
                {
                    categories = LiquidAnonymousObject.GetCategoriesLiquid(cats)
                };

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


                var dic = new Dictionary <String, String>();
                dic.Add(StoreConstants.PageOutput, indexPageOutput);
                dic.Add(StoreConstants.PageSize, categories.pageSize.ToStr());
                dic.Add(StoreConstants.PageNumber, categories.page.ToStr());
                dic.Add(StoreConstants.TotalItemCount, categories.totalItemCount.ToStr());
                //dic.Add(StoreConstants.IsPagingUp, pageDesign.IsPagingUp ? Boolean.TrueString : Boolean.FalseString);
                //dic.Add(StoreConstants.IsPagingDown, pageDesign.IsPagingDown ? Boolean.TrueString : Boolean.FalseString);

                result.LiquidRenderedResult = dic;
                result.PageDesingName       = pageDesign.Name;
            }
            catch (Exception exception)
            {
                Logger.Error(exception, "GetCategoriesIndexPage : categories and pageDesign", String.Format("Categories Items Count : {0}", categories.items.Count));
            }

            return(result);
        }
Exemple #3
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);
        }