Beispiel #1
0
        public async Task <Product> FindProductByIdForCartNoFreshen(int id)
        {
            var helper = new ProductSearchHelper(_context);
            var p      = await helper
                         .IncludeImages()
                         .IncludeExtras()
                         .IncludeCoupons()
                         .WithId(id);

            return(p);
        }
Beispiel #2
0
        public async Task <int> CountProducts(string category, double minPrice, double maxPrice, int status,
                                              ICollection <string> origins, ICollection <string> materials, ICollection <int> brands, bool includeHidden)
        {
            var searcher = new ProductSearchHelper(_context);

            return(await searcher
                   .FromCategory(category)
                   .FromPrice(minPrice)
                   .ToPrice(maxPrice)
                   .IncludeHidden(includeHidden)
                   .HasOrigin(origins)
                   .HasMaterial(materials)
                   .HasBrand(brands)
                   .Count());
        }
Beispiel #3
0
        public async Task <ICollection <Product> > SearchProducts(int page, int pageSize, string category, double minPrice,
                                                                  double maxPrice, int status, ICollection <string> origins, ICollection <string> materials,
                                                                  ICollection <int> brands, int sortType, bool includeHidden)
        {
            var searcher = new ProductSearchHelper(_context);

            return(await searcher
                   .FromCategory(category)
                   .FromPrice(minPrice)
                   .ToPrice(maxPrice)
                   .IncludeHidden(includeHidden)
                   .HasOrigin(origins)
                   .HasMaterial(materials)
                   .HasBrand(brands)
                   .SortBy((Consts.SortType)sortType)
                   .IncludeBrands()
                   .IncludeCategory()
                   .IncludeImages()
                   .Page(page, pageSize)
                   .Get());
        }
Beispiel #4
0
        public async Task <ICollection <Product> > SearchTopProducts(int top)
        {
            var searcher = new ProductSearchHelper(_context);
            var col      = await searcher
                           .IncludeImages()
                           .IncludeOrderItems()
                           .Get();

            col.ForEach(p =>
            {
                p.TotalEarningBackup = p.TotalEarning;
                p.QuantitySoldBackup = p.QuantitySold;
                p.OrderItems         = null;
                p.Brand    = null;
                p.Category = null;
            });
            col = col.OrderByDescending(p => p.TotalEarningBackup)
                  .Where(p => p.TotalEarningBackup > 0)
                  .Take(top).ToList();
            return(col);
        }