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 = _userRepository.Count(); var totalPages = (int)Math.Ceiling((double)totalUsers / pageSize); IEnumerable <User> _users = _userRepository .AllIncluding(u => u.SchedulesCreated) .OrderBy(u => u.Id) .Skip((currentPage - 1) * currentPageSize) .Take(currentPageSize) .ToList(); IEnumerable <UserViewModel> _usersVM = Mapper.Map <IEnumerable <User>, IEnumerable <UserViewModel> >(_users); Response.AddPagination(page, pageSize, totalUsers, totalPages); return(new OkObjectResult(_usersVM)); }