Esempio n. 1
0
 private IQueryable <ProductFavorite> AddFilterOnQuery(
     GetAllProductFavoritesFilter filter,
     IQueryable <ProductFavorite> queryable
     )
 {
     return(queryable);
 }
Esempio n. 2
0
        public async Task <int> CountAllAsync(
            PaginationFilter pagination,
            GetAllProductFavoritesFilter filter = null
            )
        {
            var queryable = _context.ProductFavorites.AsQueryable();

            queryable = AddFilterOnQuery(filter, queryable);
            return(await queryable.CountAsync());
        }
Esempio n. 3
0
        public async Task <IEnumerable <ProductFavorite> > GetAllAsync(
            int userId,
            PaginationFilter pagination,
            GetAllProductFavoritesFilter filter = null
            )
        {
            var customer = await _context.Customers.SingleOrDefaultAsync(c => c.UserId == userId);

            var queryable = _context.ProductFavorites.AsQueryable();

            queryable = AddFilterOnQuery(filter, queryable);

            var skip = (pagination.PageNumber - 1) * pagination.PageSize;

            return(await queryable
                   .Where(c => c.CustomerId == customer.Id)
                   .Skip(skip)
                   .Take(pagination.PageSize)
                   .Include(pdf => pdf.ProductTier)
                   .ThenInclude(pt => pt.Product)
                   .ThenInclude(p => p.ProductImages)
                   .ToListAsync());
        }