Esempio n. 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);
        }
Esempio n. 2
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);
        }