diff --git a/backend/API/Controllers/RecipeController.cs b/backend/API/Controllers/RecipeController.cs
index 5fa9bdf..d2c65ea 100644
--- a/backend/API/Controllers/RecipeController.cs
+++ b/backend/API/Controllers/RecipeController.cs
@@ -20,6 +20,10 @@ namespace API.Controllers
_openAiRecipes = openAiRecipes;
}
+ ///
+ /// Gets the userId from the jwt token amd returns a list of recipes without their ingredients and directions
+ ///
+ /// returns a okobjectresult with a list of recipes if it fails it returns a confliftobjectresult with a message of why it failed
[Authorize]
[HttpGet("getall")]
public async Task ReadRecipes()
@@ -30,6 +34,11 @@ namespace API.Controllers
return await _recipeLogic.GetRecipes(userId);
}
+ ///
+ /// Gets a specifik recipe including the ingredients and directions
+ ///
+ /// The recipe that is you want
+ /// returns a okobjectresult with a recipe if it fails it returns a confliftobjectresult with a message of why it failed
[Authorize]
[HttpGet("get/{recipeId}")]
public async Task ReadRecipe(int recipeId)
@@ -37,13 +46,27 @@ namespace API.Controllers
return await _recipeLogic.GetRecipe(recipeId);
}
+ ///
+ /// Creates a recipe and adds it to the users recipes
+ ///
+ /// The recipe to be added
+ /// returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed
[Authorize]
[HttpPost("create/{RecipesId}")]
- public async Task CreateRecipe([FromBody] RecipeDTO recipe, int RecipesId)
+ public async Task CreateRecipe([FromBody] RecipeDTO recipe)
{
- return await _recipeLogic.CreateRecipe(recipe, RecipesId);
+ var claims = HttpContext.User.Claims;
+ string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
+ int userId = Convert.ToInt32(userIdString);
+ return await _recipeLogic.CreateRecipe(recipe, userId);
}
+ ///
+ /// Edits a recipe
+ ///
+ /// the edited recipe
+ /// the recipe to be edited
+ /// returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed
[Authorize]
[HttpPut("edit/{recipeId}")]
public async Task EditRecipe([FromBody] RecipeDTO recipe, int recipeId)
@@ -54,6 +77,11 @@ namespace API.Controllers
return await _recipeLogic.EditRecipe(recipe, recipeId, userId);
}
+ ///
+ /// Deletess a recipe
+ ///
+ /// the id of the recipe to be deleted
+ /// returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed
[Authorize]
[HttpDelete("delete/{recipeId}")]
public async Task DeleteRecipe(int recipeId)
@@ -61,6 +89,11 @@ namespace API.Controllers
return await _recipeLogic.DeleteRecipe(recipeId);
}
+ ///
+ /// Generates a recipe using chatgpt
+ ///
+ /// Contains all the infomation that is needed to generate a recipe
+ /// returns a list of generated recipes
[Authorize]
[HttpPost("chatbot")]
public async Task GenerateRecipe([FromBody] GenerateRecipeDTO recipeDTO)