public ActionResult <IngredientDto> AddIngredientList(int recipeId, [FromBody] List <IngredientForCreationDto> ingredientsForCreation) { // delete the previous list /*var parameters = new IngredientParametersDto { Filters = $"RecipeId = {recipeId}", PageSize = 10 }; * var ingredientsFromRepo = _ingredientRepository.GetIngredients(parameters);*/ _ingredientRepository.DeleteIngredients(recipeId); // then add the new one var ingredients = _mapper.Map <List <Ingredient> >(ingredientsForCreation); _ingredientRepository.AddIngredients(ingredients); // save and return new one _ingredientRepository.Save(); var ingredientDto = _mapper.Map <List <IngredientDto> >(ingredients); return(CreatedAtRoute("GetIngredients", 1, //new { ingredientDto.RecipeId }, ingredientDto)); }