public ActionResult <IEnumerable <TastingNoteDto> > GetTastingNotes( int brewId, [FromQuery] TastingNotesResourceParameters tastingNotesResourceParameters, [FromHeader(Name = ExtendedControllerBase.ACCEPT)] string mediaTypes) { if (!_propertyMappingService.ValidMappingExistsFor <TastingNoteDto, Entities.TastingNote> (tastingNotesResourceParameters.OrderBy)) { return(BadRequest()); } var splitMediaTypes = mediaTypes.Split(','); if (!MediaTypeHeaderValue.TryParseList(splitMediaTypes, out IList <MediaTypeHeaderValue> parsedMediaTypes)) { return(BadRequest()); } tastingNotesResourceParameters.BrewId = brewId; var tastingNotes = _homebrewRepository.GetTastingNotes(tastingNotesResourceParameters); var paginationMetaData = new { totalCount = tastingNotes.TotalCount, pageSize = tastingNotes.PageSize, currentPage = tastingNotes.CurrentPage, totalPages = tastingNotes.TotalPages }; Response.Headers.Add(this.PAGINATION_HEADER, JsonSerializer.Serialize(paginationMetaData)); var shapedTastingNotes = _mapper.Map <IEnumerable <TastingNoteDto> >(tastingNotes) .ShapeData(null); if (parsedMediaTypes.Any(pmt => pmt.SubTypeWithoutSuffix.EndsWith(this.HATEOAS, StringComparison.InvariantCultureIgnoreCase))) { var links = CreateLinksForTastingNotes(tastingNotesResourceParameters, tastingNotes.HasNext, tastingNotes.HasPrevious); var shapedTastingNotesWithLinks = shapedTastingNotes.Select(tastingNote => { var tastingNoteAsDictionary = tastingNote as IDictionary <string, object>; var tastingNoteLinks = CreateLinksForTastingNote(brewId, (int)tastingNoteAsDictionary["Id"]); tastingNoteAsDictionary.Add(this.LINKS, tastingNoteLinks); return(tastingNoteAsDictionary); }); var linkedCollectionResource = new { value = shapedTastingNotesWithLinks, links }; return(Ok(linkedCollectionResource)); } return(Ok(shapedTastingNotes)); }