public ActionResult <IEnumerable <RecipeWithoutStepsDto> > GetRecipes( [FromQuery] RecipesResourceParameters recipesResourceParameters, [FromHeader(Name = ExtendedControllerBase.ACCEPT)] string mediaTypes) { if (!_propertyMappingService.ValidMappingExistsFor <RecipeDto, Entities.Recipe> (recipesResourceParameters.OrderBy)) { return(BadRequest()); } var splitMediaTypes = mediaTypes.Split(','); if (!MediaTypeHeaderValue.TryParseList(splitMediaTypes, out IList <MediaTypeHeaderValue> parsedMediaTypes)) { return(BadRequest()); } var recipes = _homeBrewRepository.GetRecipes(recipesResourceParameters); var paginationMetaData = new { totalCount = recipes.TotalCount, pageSize = recipes.PageSize, currentPage = recipes.CurrentPage, totalPages = recipes.TotalPages }; Response.Headers.Add(this.PAGINATION_HEADER, JsonSerializer.Serialize(paginationMetaData)); var shapedRecipes = _mapper.Map <IEnumerable <RecipeWithoutStepsDto> >(recipes) .ShapeData(null); if (parsedMediaTypes.Any(pmt => pmt.SubTypeWithoutSuffix.EndsWith(this.HATEOAS, StringComparison.InvariantCultureIgnoreCase))) { var links = CreateLinksForRecipes(recipesResourceParameters, recipes.HasNext, recipes.HasPrevious); var shapedRecipesWithLinks = shapedRecipes.Select(recipe => { var recipeAsDictionary = recipe as IDictionary <string, object>; var recipeLinks = CreateLinksForRecipe((int)recipeAsDictionary["Id"], false); recipeAsDictionary.Add(this.LINKS, recipeLinks); return(recipeAsDictionary); }); var linkedCollectionResouce = new { value = shapedRecipesWithLinks, links }; return(Ok(linkedCollectionResouce)); } return(Ok(shapedRecipes)); }