public IActionResult GetAuthors([FromQuery] AuthorsResourceParameters authorsResourceParameters) { if (!_propertyMappingService.ValidMappingExistFor <AuthorDto, Author>(authorsResourceParameters.OrderBy) || !_propertyCheckerService.TypeHasProperty <AuthorDto>(authorsResourceParameters.Fields)) { return(BadRequest()); } var authors = _courseLibraryRepository.GetAuthors(authorsResourceParameters); var metadata = PaginationMetadata.Create(authors); Response.Headers.Add("X-Pagination", JsonSerializer.Serialize(metadata)); var links = GetLinksForAuthors(authorsResourceParameters, authors.HasNext, authors.HasPrevious); var shapedAuthors = _mapper.Map <IEnumerable <AuthorDto> >(authors) .ShapeData(authorsResourceParameters.Fields); var shapedAuthorsWithLinks = shapedAuthors.Select(sa => { var shapedAuthor = sa as IDictionary <string, object>; var authorLinks = GetLinksForAuthor((Guid)shapedAuthor["Id"]); shapedAuthor.Add("links", authorLinks); return(shapedAuthor); }); return(Ok(new { value = shapedAuthorsWithLinks, links })); }