When getting a single recipe the directions is in a string array

This commit is contained in:
Jeas0001 2025-05-13 10:45:46 +02:00
parent 1dd98e1a05
commit 73cec5745b
2 changed files with 29 additions and 1 deletions

View File

@ -40,7 +40,19 @@ namespace API.BusinessLogic
if (recipe == null || recipe.Id == 0) { return new ConflictObjectResult(new { message = "Could not find any recipe" }); }
return new OkObjectResult(recipe);
var singleRecipeDTO = new GetSingleRecipeDTO();
singleRecipeDTO.Id = recipe.Id;
singleRecipeDTO.Name = recipe.Name;
singleRecipeDTO.Description = recipe.Description;
singleRecipeDTO.Ingredients = recipe.Ingredients;
singleRecipeDTO.Directions = new List<string>();
foreach (var item in recipe.Directions)
{
string directions = item.Instruktions;
singleRecipeDTO.Directions.Add(directions);
}
return new OkObjectResult(singleRecipeDTO);
}
/// <summary>

View File

@ -0,0 +1,16 @@
namespace API.Models.RecipeModels
{
public class GetSingleRecipeDTO
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public List<string> Directions { get; set; }
public List<Ingredient> Ingredients { get; set; }
}
}