Esempio n. 1
0
 public async Task<int> CountBrands(string phrase, int sortType)
 {
     var searcher = new BrandSearchHelper(_context);
     return await searcher
         .Active()
         .IncludeCountPublic()
         .Like(phrase)
         .Count();
 }
Esempio n. 2
0
 public async Task<ICollection<Brand>> SearchBrands()
 {
     var searcher = new BrandSearchHelper(_context);
     return await searcher
         .Active()
         .IncludeCountPublic()
         .SortBy(Consts.SortType.Popularity)
         .Get();
 }
Esempio n. 3
0
 public async Task<ICollection<Brand>> SearchTopBrands(int top)
 {
     var searcher = new BrandSearchHelper(_context);
     var col = await searcher
         .Active()
         .IncludeCountPublic()
         .IncludeProducts()
         .AsNoTracking()
         .Get();
     col.ForEach(b =>
     {
         b.AverageRatingBackup = b.AverageRating;
         b.QuantitySoldBackup = b.QuantitySold;
         b.TotalEarningBackup = b.TotalEarning;
         b.ProductCount = b.Products.Count;
     });
     return col.OrderByDescending(c => c.TotalEarningBackup).Where(c => c.TotalEarningBackup > 0).Take(top).ToList();
 }
Esempio n. 4
0
 public async Task<ICollection<Brand>> SearchBrands(string phrase, int sortType, int page, int pageSize)
 {
     var searcher = new BrandSearchHelper(_context);
     var col = await searcher
         .Active()
         .IncludeCountPublic()
         .Like(phrase)
         .SortBy((Consts.SortType) sortType)
         .IncludeProducts()
         .AsNoTracking()
         .Page(page, pageSize)
         .Get();
     col.ForEach(b =>
     {
         b.AverageRatingBackup = b.AverageRating;
         b.QuantitySoldBackup = b.QuantitySold;
         b.TotalEarningBackup = b.TotalEarning;
         b.ProductCount = b.Products.Count;
     });
     return col;
 }