public IActionResult Get(int pageNo, int pageSize) { var data = _context.Scooters.OrderBy(s => s.Id).ToList(); var page = new PaginatedResponse <Scooter>(data, pageNo, pageSize); var totalCount = data.Count(); var totalPages = Math.Ceiling((double)totalCount / pageSize); return(Ok(new { Page = page, TotalPages = totalPages })); }
public IActionResult Get(int pageIndex, int pageSize) { var data = _context.Orders.Include(o => o.Customer) .OrderByDescending(c => c.Placed); var page = new PaginatedResponse <Order>(data, pageIndex, pageSize); var totalCount = data.Count(); var totalPages = Math.Ceiling((double)totalCount / pageSize); var response = new { Page = page, TotalPages = totalPages }; return(Ok(response)); }