public async Task <PagedList <Rental> > GetRentals(RentalParams rentalParams) { var rentals = _context .Rentals .Include(c => c.Car).ThenInclude(c => c.CarCategory) .Include(u => u.User) .Include(p => p.PickUpLocation) .Include(d => d.DropOffLocation); return(await PagedList <Rental> .CreateAsync(rentals, rentalParams.PageNumber, rentalParams.PageSize)); }
public async Task <ActionResult> GetRentals([FromQuery] RentalParams rentalParams) { var rentals = await _repo.GetRentals(rentalParams); if (rentals == null) { return(NotFound()); } Response.AddPagination(rentals.CurrentPage, rentals.PageSize, rentals.TotalCount, rentals.TotalPages); return(Ok(rentals)); }