public ActionResult <TastingNoteDto> CreateTastingNote(int brewId, [FromBody] TastingNoteForCreationDto tastingNote, [FromHeader(Name = ExtendedControllerBase.ACCEPT)] string mediaTypes) { var splitMediaTypes = mediaTypes.Split(','); if (!MediaTypeHeaderValue.TryParseList(splitMediaTypes, out IList <MediaTypeHeaderValue> parsedMediaTypes)) { return(BadRequest()); } if (!_homebrewRepository.BrewExists(brewId)) { return(NotFound()); } var includeAdditionalInfo = true; var finalTastingNote = _mapper.Map <Entities.TastingNote>(tastingNote); _homebrewRepository.AddTastingNote(finalTastingNote); finalTastingNote.Brew = _homebrewRepository.GetBrew(brewId, includeAdditionalInfo); _homebrewRepository.Save(); var tastingNoteToReturn = _mapper.Map <Models.TastingNoteDto>(finalTastingNote); if (parsedMediaTypes.Any(pmt => pmt.SubTypeWithoutSuffix.EndsWith(this.HATEOAS, StringComparison.InvariantCultureIgnoreCase))) { var links = CreateLinksForTastingNote(brewId, tastingNoteToReturn.Id); var linkedResourcesToReturn = tastingNote.ShapeData(null) as IDictionary <string, object>; linkedResourcesToReturn.Add(this.LINKS, links); return(CreatedAtRoute( "GetTastingNote", new { brewId, id = linkedResourcesToReturn["Id"] }, linkedResourcesToReturn)); } return(CreatedAtRoute( "GetTastingNote", new { brewId, id = tastingNoteToReturn.Id }, tastingNoteToReturn)); }