public IActionResult GetTags(int pageNumber = 1, int pageSize = 5) { pageSize = pageSize > maxPageSize ? maxPageSize : pageSize; var data = _dataService.GetTags(pageNumber, pageSize); var result = Mapper.Map <IEnumerable <TagListModel> >(data); foreach (TagListModel p in result) { p.Url = Url.Link(nameof(GetTag), new{ p.Id }); } var prevlink = pageNumber > 1 ? Url.Link(nameof(GetTags), new { pageNumber = pageNumber - 1, pageSize }) : null; var total = _dataService.GetNumberOfTags(); var totalPages = (int)System.Math.Ceiling(total / (double)pageSize); var nextlink = pageNumber < totalPages ? Url.Link(nameof(GetTags), new { pageNumber = pageNumber + 1, pageSize }) : null; var curlink = Url.Link(nameof(GetTags), new { pageNumber, pageSize }); var linkedResult = new { Result = result, Links = new List <object> { new { name = "prev", url = prevlink }, new { name = "next", url = nextlink }, new { name = "cur", url = curlink } } }; return(Ok(linkedResult)); }