I'm trying to make pagination in a Customer controller using ASP 5.0 WebAPI. When I try to do this example I get:
Cannot implicitly convert type Microsoft.AspNet.Mvc.HttpOkObjectResult to API.Controllers.IHttpActionResult
I just need to return a collection of customers with the number of the current page, total of pages and results.
public IHttpActionResult Get(int offset = 0, int limit = 50) { // Get total number of records int total = _dbContext.Customers.Count(); // Select the customers based on paging parameters var customers = _dbContext.Customers .OrderBy(c => c.Id) .Skip(offset) .Take(limit) .ToList(); // Return the list of customers return Ok(new { Data = customers, Paging = new { Total = total, Limit = limit, Offset = offset, Returned = customers.Count } }); }
IHttpActionResulttoIActionResult