Beispiel #1
0
 public async Task<int> CountBrands(string phrase, int sortType)
 {
     var searcher = new BrandSearchHelper(_context);
     return await searcher
         .Active()
         .IncludeCountPublic()
         .Like(phrase)
         .Count();
 }
Beispiel #2
0
 public async Task<ICollection<Brand>> SearchBrands()
 {
     var searcher = new BrandSearchHelper(_context);
     return await searcher
         .Active()
         .IncludeCountPublic()
         .SortBy(Consts.SortType.Popularity)
         .Get();
 }
Beispiel #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();
 }
Beispiel #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;
 }