public async Task <StorePagedList <Content> > GetContentsCategoryIdAsync(int storeId, int?categoryId, string typeName, bool?isActive, int page, int pageSize, string search) { Expression <Func <Content, bool> > match = r2 => r2.StoreId == storeId && r2.State == (isActive.HasValue ? isActive.Value : r2.State) && typeName.Equals(r2.Type, StringComparison.InvariantCultureIgnoreCase) && r2.CategoryId == (categoryId.HasValue ? categoryId.Value : r2.CategoryId); var predicate = PredicateBuilder.Create <Content>(match); if (!String.IsNullOrEmpty(search.ToStr())) { predicate = predicate.And(r => r.Name.Contains(search.ToLower())); } Expression <Func <Content, object> > includeProperties = r => r.ContentFiles.Select(r1 => r1.FileManager); Expression <Func <Content, int> > keySelector = t => t.Ordering; var items = await this.FindAllIncludingAsync(predicate, page, pageSize, keySelector, OrderByType.Descending, includeProperties); var totalItemNumber = await this.CountAsync(predicate); var task = Task.Factory.StartNew(() => { StorePagedList <Content> resultItems = new StorePagedList <Content>(items, page, pageSize, totalItemNumber); return(resultItems); }); var result = await task; return(result); }
public StorePagedList <Content> GetContentsCategoryId(int storeId, int?categoryId, string typeName, bool?isActive, int page, int pageSize) { String key = String.Format("Store-{0}-GetContentsCategoryId-{1}-{2}-{3}-{4}-{5}", storeId, typeName, categoryId, isActive.HasValue ? isActive.Value.ToStr() : "", page, pageSize); StorePagedList <Content> items = null; _contentCacheStorePagedList.IsCacheEnable = this.IsCacheEnable; _contentCacheStorePagedList.TryGet(key, out items); if (items == null) { var returnList = this.GetAllIncluding(r => r.ContentFiles.Select(r1 => r1.FileManager)) .Where(r2 => r2.StoreId == storeId && r2.Type.Equals(typeName, StringComparison.InvariantCultureIgnoreCase)); if (categoryId.HasValue) { returnList = returnList.Where(r => r.CategoryId == categoryId.Value); } if (isActive.HasValue) { returnList = returnList.Where(r => r.State == isActive); } var cat = returnList.OrderByDescending(r => r.Id).ToList(); items = new StorePagedList <Content>(cat.Skip((page - 1) * pageSize).Take(pageSize).ToList(), page, pageSize, cat.Count()); // items = new PagedList<Content>(cat, page, cat.Count()); // items = (PagedList<Content>) cat.ToPagedList(page, pageSize); _contentCacheStorePagedList.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(this.CacheMinute)); } return(items); }
public StoreLiquidResult GetPhotoGalleryIndexPage(PageDesign pageDesign, StorePagedList <FileManager> fileManagers) { var cats = new List <FileManagerLiquid>(); foreach (var item in fileManagers.items) { cats.Add(new FileManagerLiquid(item, ImageWidth, ImageHeight)); } object anonymousObject = new { photogalleries = LiquidAnonymousObject.GetFileManagerLiquidEnumerable(cats) }; var indexPageOutput = LiquidEngineHelper.RenderPage(pageDesign, anonymousObject); var dic = new Dictionary <String, String>(); dic.Add(StoreConstants.PageOutput, indexPageOutput); dic.Add(StoreConstants.PageSize, fileManagers.pageSize.ToStr()); dic.Add(StoreConstants.PageNumber, fileManagers.page.ToStr()); dic.Add(StoreConstants.TotalItemCount, fileManagers.totalItemCount.ToStr()); var result = new StoreLiquidResult(); result.LiquidRenderedResult = dic; result.PageDesingName = pageDesign.Name; return(result); }
public async Task <StorePagedList <FileManager> > GetImagesByFileSizeAsync(int storeId, string imageSourceType, string fileSizes, int page, int pageSize) { try { String[] fSize = fileSizes.Split(",".ToCharArray()); Expression <Func <FileManager, bool> > match = r2 => r2.StoreId == storeId && r2.State && fSize.Contains(r2.FileSize) && r2.ImageSourceType.Equals(imageSourceType, StringComparison.InvariantCultureIgnoreCase); Expression <Func <FileManager, int> > keySelector = t => t.Ordering; var items = this.Paginate(page, pageSize, keySelector, match); var task = Task.Factory.StartNew(() => { StorePagedList <FileManager> resultItems = new StorePagedList <FileManager>(items, items.PageIndex, items.PageSize, items.TotalCount); return(resultItems); }); var result = await task; return(result); } catch (Exception exception) { Logger.Error(exception); return(null); } }
public async Task <StorePagedList <Product> > GetProductsCategoryIdAsync(int storeId, int?categoryId, string typeName, bool?isActive, int page, int pageSize, string search, string filters) { int?catId = categoryId.HasValue && categoryId > 0 ? categoryId : null; Expression <Func <Product, bool> > match = r2 => r2.StoreId == storeId && r2.State == (isActive.HasValue ? isActive.Value : r2.State) && r2.ProductCategoryId == (catId.HasValue ? catId.Value : r2.ProductCategoryId); Expression <Func <Product, object> > includeProperties = r => r.ProductFiles.Select(r1 => r1.FileManager); var predicate = PredicateBuilder.Create <Product>(match); if (!String.IsNullOrEmpty(search.ToStr())) { predicate = predicate.And(r => r.Name.ToLower().Contains(search.ToLower().Trim())); } if (!String.IsNullOrEmpty(filters.ToStr())) { } var items = await this.FindAllIncludingAsync(predicate, page, pageSize, r => r.Ordering, OrderByType.Descending, includeProperties); var totalItemNumber = await this.CountAsync(predicate); var task = Task.Factory.StartNew(() => { StorePagedList <Product> resultItems = new StorePagedList <Product>(items, page, pageSize, totalItemNumber); return(resultItems); }); var result = await task; return(result); }
public StorePagedList <FileManager> GetImagesByStoreId(int storeId, int page, int pageSize) { String key = String.Format("StoreFileManager-{0}", storeId); StorePagedList <FileManager> items = null; StorePagedListFileManagerCache.TryGet(key, out items); if (items == null) { var images = FindBy(r => r.StoreId == storeId).ToList(); items = new StorePagedList <FileManager>(images.Skip((page - 1) * pageSize).Take(pageSize).ToList(), page, pageSize, images.Count()); StorePagedListFileManagerCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("FileManager_CacheAbsoluteExpiration_Minute", 10))); } return(items); }
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 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 async Task <StorePagedList <ProductCategory> > GetProductCategoriesByStoreIdAsync(int storeId, string type, bool?isActive, int page, int pageSize = 25) { Expression <Func <ProductCategory, bool> > match = r2 => r2.StoreId == storeId && r2.State == isActive.HasValue ? isActive.Value : r2.State && r2.CategoryType.Equals(type, StringComparison.InvariantCultureIgnoreCase); var items = this.Paginate(page, pageSize, r => r.Ordering, match); var res = Task.Factory.StartNew(() => { StorePagedList <ProductCategory> result = null; result = new StorePagedList <ProductCategory>(items, items.PageIndex, items.PageSize, items.TotalCount); return(result); }); return(await res); }
public CategoryViewModel GetCategory(string id, int page, String categoryType) { var returnModel = new CategoryViewModel(); int categoryId = id.Split("-".ToCharArray()).Last().ToInt(); StorePagedList <Content> task2 = ContentRepository.GetContentsCategoryId(MyStore.Id, categoryId, categoryType, true, page, 600); returnModel.SCategories = CategoryRepository.GetCategoriesByStoreId(MyStore.Id, categoryType, true); returnModel.SStore = MyStore; returnModel.SCategory = CategoryRepository.GetCategory(categoryId); returnModel.Type = categoryType; returnModel.SNavigations = NavigationRepository.GetStoreActiveNavigations(this.MyStore.Id); returnModel.SContents = new PagedList <Content>(task2.items, task2.page - 1, task2.pageSize, task2.totalItemCount); return(returnModel); }
public async Task <StorePagedList <Brand> > GetBrandsByStoreIdWithPagingAsync(int storeId, bool?isActive, int page = 1, int pageSize = 25) { Expression <Func <Brand, bool> > match = r2 => r2.StoreId == storeId && r2.State == (isActive.HasValue ? isActive.Value : r2.State); var predicate = PredicateBuilder.Create <Brand>(match); var items = await this.FindAllAsync(predicate, r => r.Ordering, OrderByType.Descending, page, pageSize); var totalItemNumber = await this.CountAsync(predicate); var task = Task.Factory.StartNew(() => { var resultItems = new StorePagedList <Brand>(items, page, pageSize, totalItemNumber); return(resultItems); }); var result = await task; return(result); }
public StoreLiquidResult GetCategoriesIndexPage(PageDesign pageDesign, StorePagedList <ProductCategory> categories) { var result = new StoreLiquidResult(); result.PageDesingName = pageDesign.Name; try { if (pageDesign == null) { throw new Exception("PageDesing is null"); } var cats = new List <ProductCategoryLiquid>(); foreach (var item in categories.items) { cats.Add(new ProductCategoryLiquid(item)); } object anonymousObject = new { 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, 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; } catch (Exception exception) { Logger.Error(exception, "GetCategoriesIndexPage : categories and pageDesign", String.Format("Categories Items Count : {0}", categories.items.Count)); } return(result); }
public async Task <StorePagedList <Category> > GetCategoriesByStoreIdWithPagingAsync(int storeId, string type, bool?isActive, int page = 1, int pageSize = 25) { Expression <Func <Category, bool> > match = r2 => r2.StoreId == storeId && r2.State == (isActive.HasValue ? isActive.Value : r2.State) & r2.CategoryType.Equals(type, StringComparison.InvariantCultureIgnoreCase); Expression <Func <Category, int> > keySelector = t => t.Ordering; var items = await this.FindAllAsync(match, keySelector, OrderByType.Descending, page, pageSize); var totalItemNumber = await this.CountAsync(match); var task = Task.Factory.StartNew(() => { StorePagedList <Category> resultItems = new StorePagedList <Category>(items, page, pageSize, totalItemNumber); return(resultItems); }); var result = await task; return(result); }
public StoreLiquidResult GetBrandsIndexPage(PageDesign pageDesign, StorePagedList <Brand> brands) { var result = new StoreLiquidResult(); try { var brandList = new List <BrandLiquid>(); foreach (var item in brands.items) { brandList.Add(new BrandLiquid(item, this.ImageWidth, this.ImageHeight)); } object anonymousObject = new { brands = LiquidAnonymousObject.GetBrandsEnumerable(brandList) }; var indexPageOutput = LiquidEngineHelper.RenderPage(pageDesign, anonymousObject); var dic = new Dictionary <String, String>(); dic.Add(StoreConstants.PageOutput, indexPageOutput); dic.Add(StoreConstants.PageSize, brands.pageSize.ToStr()); dic.Add(StoreConstants.PageNumber, brands.page.ToStr()); dic.Add(StoreConstants.TotalItemCount, brands.totalItemCount.ToStr()); result.LiquidRenderedResult = dic; result.PageDesingName = pageDesign.Name; } catch (Exception exception) { Logger.Error(exception, "GetbrandsIndexPage : brands and pageDesign", String.Format("brands Items Count : {0}", brands.items.Count)); } return(result); }
public StorePagedList <ProductCategory> GetProductCategoryWithContents(int categoryId, int page, int pageSize = 25) { String key = String.Format("GetProductCategoryWithContents-{0}-{1}", categoryId, page); StorePagedList <ProductCategory> items = null; PagingProductCategoryCache.TryGet(key, out items); if (items == null) { IQueryable <ProductCategory> cats = StoreDbContext.ProductCategories.Where(r => r.Id == categoryId && r.Products.Any()) .Include( r => r.Products.Select( r1 => r1.ProductFiles.Select(m => m.FileManager))) .OrderByDescending(r => r.Ordering); var c = cats.ToList(); items = new StorePagedList <ProductCategory>(c.Skip((page - 1) * pageSize).Take(pageSize).ToList(), page, c.Count()); PagingProductCategoryCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("ProductCategories_CacheAbsoluteExpiration_Minute", 10))); } return(items); }