public IActionResult Get() { var pagination = Request.Headers["Pagination"]; if (!string.IsNullOrEmpty(pagination)) { string[] vals = pagination.ToString().Split(','); int.TryParse(vals[0], out page); int.TryParse(vals[1], out pageSize); } int currentPage = page; int currentPageSize = pageSize; var totalUsers = _authorRepository.Count(); var totalPages = (int)Math.Ceiling((double)totalUsers / pageSize); IEnumerable <Author> _authors = _authorRepository .AllIncluding(a => a.BooksCreated) .OrderBy(u => u.Id) .Skip((currentPage - 1) * currentPageSize) .Take(currentPageSize) .ToList(); IEnumerable <AuthorViewModel> _authorVM = Mapper.Map <IEnumerable <Author>, IEnumerable <AuthorViewModel> >(_authors); Response.AddPagination(page, pageSize, totalUsers, totalPages); return(new OkObjectResult(_authorVM)); }