public ActionResult <IEnumerable <IngredientDto> > GetIngredients(int recipeId, int recipeStepId) { try { if (!_homeBrewRepository.RecipeExists(recipeId)) { _logger.LogInformation($"Recipe with id {recipeId} wasn't found when accessing ingredients"); return(NotFound()); } if (!_homeBrewRepository.RecipeStepExists(recipeStepId)) { _logger.LogInformation($"Recipe step with id {recipeStepId} wasn't found when accessing ingredients"); return(NotFound()); } var ingredientsForRecipe = _homeBrewRepository.GetIngredientsForRecipeStep(recipeStepId); return(Ok(_mapper.Map <IEnumerable <IngredientDto> >(ingredientsForRecipe))); } catch (Exception ex) { _logger.LogCritical($"Exception while getting ingredients for recipe step with id {recipeStepId}.", ex); return(StatusCode(500, "A problem happened while handling your request.")); } }