private IQueryable <ProductTier> AddFilterOnQuery( GetAllProductTiersFilter filter, IQueryable <ProductTier> queryable ) { queryable = queryable.Where(x => x.IsDeleted == false); if (filter?.ProductId > 0) { queryable = queryable.Where(x => x.ProductId == filter.ProductId); } if (filter?.TierId > 0) { queryable = queryable.Where(x => x.TierId == filter.TierId); } if (filter?.Quantity > 0) { queryable = queryable.Where(x => x.Quantity == filter.Quantity); } if (filter?.DiscountPercentage > 0) { queryable = queryable.Where(x => x.DiscountPercentage == filter.DiscountPercentage); } if (filter?.AfterDiscountPrice > 0) { queryable = queryable.Where(x => x.AfterDiscountPrice == filter.AfterDiscountPrice); } return(queryable); }
public async Task <int> CountAllAsync( PaginationFilter pagination, GetAllProductTiersFilter filter = null ) { var queryable = _context.ProductTiers.AsQueryable(); queryable = queryable.Where(x => x.IsDeleted == false); queryable = AddFilterOnQuery(filter, queryable); return(await queryable.CountAsync()); }
public async Task <IEnumerable <ProductTier> > GetAllAsync( PaginationFilter pagination, GetAllProductTiersFilter filter = null) { var queryable = _context.ProductTiers.AsQueryable(); queryable = AddFilterOnQuery(filter, queryable); var skip = (pagination.PageNumber - 1) * pagination.PageSize; return(await queryable .Skip(skip) .Take(pagination.PageSize) .Include(pt => pt.Product) .ToListAsync()); }