public static object GetProductAnonymousObject(ProductLiquid s) { object anonymousObject = new { CategoryName = s.Category.Name, CategoryId = s.Product.ProductCategoryId, s.Product.BrandId, CategoryDescription = s.Category.Description, ProductId = s.Product.Id, s.Product.Name, s.Product.Description, s.Product.ProductCode, s.Product.Price, s.Product.RetailerId, s.Product.Discount, s.Product.UpdatedDate, s.Product.CreatedDate, s.Product.TotalRating, s.Product.UnitsInStock, s.Product.VideoUrl, images = s.ImageLiquid }; return(anonymousObject); }
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); }
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); } }
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); } }
public StoreLiquidResult GetProductsDetailPage(Product product, PageDesign pageDesign, ProductCategory category) { if (product == null) { throw new Exception("Product is NULL"); } if (pageDesign == null) { throw new Exception("pageDesign is NULL"); } if (category == null) { throw new Exception("ProductCategory is NULL"); } var s = new ProductLiquid(product, category, ImageWidth, ImageHeight); var anonymousObject = LiquidAnonymousObject.GetProductAnonymousObject(s); var indexPageOutput = LiquidEngineHelper.RenderPage(pageDesign, anonymousObject); var dic = new Dictionary <String, String>(); dic.Add(StoreConstants.PageOutput, indexPageOutput); var result = new StoreLiquidResult(); result.PageDesingName = pageDesign.Name; result.LiquidRenderedResult = dic; result.DetailLink = s.DetailLink; return(result); }
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); } }
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); }