When getting a single recipe the directions is in a string array
This commit is contained in:
parent
1dd98e1a05
commit
73cec5745b
@ -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>
|
||||
|
16
backend/API/Models/RecipeModels/GetSingleRecipeDTO.cs
Normal file
16
backend/API/Models/RecipeModels/GetSingleRecipeDTO.cs
Normal 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; }
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user