Compare commits

..

No commits in common. "e30110bcff0d6f4db86b2fada9bba13ac796c476" and "b8026250cf64f48c72cc889e78909f59986258c9" have entirely different histories.

3 changed files with 2 additions and 105 deletions

View File

@ -20,10 +20,6 @@ namespace API.Controllers
_openAiRecipes = openAiRecipes;
}
/// <summary>
/// Gets the userId from the jwt token amd returns a list of recipes without their ingredients and directions
/// </summary>
/// <returns>returns a okobjectresult with a list of recipes if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpGet("getall")]
public async Task<IActionResult> ReadRecipes()
@ -34,11 +30,6 @@ namespace API.Controllers
return await _recipeLogic.GetRecipes(userId);
}
/// <summary>
/// Gets a specifik recipe including the ingredients and directions
/// </summary>
/// <param name="recipeId">The recipe that is you want</param>
/// <returns>returns a okobjectresult with a recipe if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpGet("get/{recipeId}")]
public async Task<IActionResult> ReadRecipe(int recipeId)
@ -46,27 +37,13 @@ namespace API.Controllers
return await _recipeLogic.GetRecipe(recipeId);
}
/// <summary>
/// Creates a recipe and adds it to the users recipes
/// </summary>
/// <param name="recipe">The recipe to be added</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPost("create/{RecipesId}")]
public async Task<IActionResult> CreateRecipe([FromBody] RecipeDTO recipe)
public async Task<IActionResult> CreateRecipe([FromBody] RecipeDTO recipe, int 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);
return await _recipeLogic.CreateRecipe(recipe, RecipesId);
}
/// <summary>
/// Edits a recipe
/// </summary>
/// <param name="recipe">the edited recipe</param>
/// <param name="recipeId">the recipe to be edited</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPut("edit/{recipeId}")]
public async Task<IActionResult> EditRecipe([FromBody] RecipeDTO recipe, int recipeId)
@ -77,11 +54,6 @@ namespace API.Controllers
return await _recipeLogic.EditRecipe(recipe, recipeId, userId);
}
/// <summary>
/// Deletess a recipe
/// </summary>
/// <param name="recipeId">the id of the recipe to be deleted</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpDelete("delete/{recipeId}")]
public async Task<IActionResult> DeleteRecipe(int recipeId)
@ -89,11 +61,6 @@ namespace API.Controllers
return await _recipeLogic.DeleteRecipe(recipeId);
}
/// <summary>
/// Generates a recipe using chatgpt
/// </summary>
/// <param name="recipeDTO">Contains all the infomation that is needed to generate a recipe</param>
/// <returns>returns a list of generated recipes</returns>
[Authorize]
[HttpPost("chatbot")]
public async Task<IActionResult> GenerateRecipe([FromBody] GenerateRecipeDTO recipeDTO)

View File

@ -1,7 +1,6 @@

using API.BusinessLogic;
using API.Models.ShoppingListModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
@ -18,11 +17,6 @@ namespace API.Controllers
_shoppingListLogic = shoppingListLogic;
}
/// <summary>
/// Gets the entire shoppinglist connected to the user
/// </summary>
/// <returns>returns a list of shoppinglist items if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpGet("get")]
public async Task<IActionResult> ReadShoppingList()
{
@ -32,12 +26,6 @@ namespace API.Controllers
return await _shoppingListLogic.ReadShoppingList(userId);
}
/// <summary>
/// Adds an item to the shopping list
/// </summary>
/// <param name="listItemDTO"></param>
/// <returns></returns>
[Authorize]
[HttpPost("add")]
public async Task<IActionResult> AddItem([FromBody] ShoppingListItemDTO listItemDTO)
{
@ -47,12 +35,6 @@ namespace API.Controllers
return await _shoppingListLogic.AddItemToShoppingList(listItemDTO, userId);
}
/// <summary>
/// Checks/Unchecks an item on the shoppinglist
/// </summary>
/// <param name="itemId">The item to be checked/unchecked</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPut("check")]
public async Task<IActionResult> CheckItem(int itemId)
{
@ -62,13 +44,6 @@ namespace API.Controllers
return await _shoppingListLogic.CheckItemInShoppingList(userId, itemId);
}
/// <summary>
/// Edits an item on the shoppinglist
/// </summary>
/// <param name="listItemDTO">The edited item</param>
/// <param name="itemId">The item to be edited</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPut("update")]
public async Task<IActionResult> UpdateItem([FromBody] ShoppingListItemDTO listItemDTO, int itemId)
{
@ -78,12 +53,6 @@ namespace API.Controllers
return await _shoppingListLogic.UpdateItemInShoppingList(userId, itemId, listItemDTO);
}
/// <summary>
/// Deletes an item on the shoppinglist
/// </summary>
/// <param name="itemId">The item to be deleted</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpDelete("delete")]
public async Task<IActionResult> DeleteItem(int itemId)
{
@ -93,12 +62,6 @@ namespace API.Controllers
return await _shoppingListLogic.DeleteItemInShoppingList(userId, itemId);
}
/// <summary>
/// Add an entire recipes ingredients to the shoppinglist
/// </summary>
/// <param name="recipeId">The recipes ingredients to be added</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPost("recipeadd")]
public async Task<IActionResult> AddARecipesItems(int recipeId)
{

View File

@ -17,10 +17,6 @@ namespace API.Controllers
_userLogic = userLogic;
}
/// <summary>
/// Gets the users email and username
/// </summary>
/// <returns>returns the users email, username and Id</returns>
[Authorize]
[HttpGet("get")]
public async Task<IActionResult> ReadUser()
@ -31,33 +27,18 @@ namespace API.Controllers
return await _userLogic.GetUser(userId);
}
/// <summary>
/// Logins a user
/// </summary>
/// <param name="loginDTO">The users login credentials</param>
/// <returns>Returns a jwttoken their username, id and a refreshtoken</returns>
[HttpPost("login")]
public async Task<IActionResult> Login([FromBody] LoginDTO loginDTO)
{
return await _userLogic.Login(loginDTO);
}
/// <summary>
/// Create a new user
/// </summary>
/// <param name="userDTO">contains the username email and password</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[HttpPost("create")]
public async Task<IActionResult> CreateUser([FromBody] CreateUserDTO userDTO)
{
return await _userLogic.RegisterUser(userDTO);
}
/// <summary>
/// Changes the password of the user
/// </summary>
/// <param name="passwordDTO">Contains the old password and the new one</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPut("change-password")]
public async Task<IActionResult> ChangePassword([FromBody] ChangePasswordDTO passwordDTO)
@ -68,11 +49,6 @@ namespace API.Controllers
return await _userLogic.ChangePassword(passwordDTO, userId);
}
/// <summary>
/// Edits the email and username of the user
/// </summary>
/// <param name="userDTO">The updated username and email</param>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPut("update")]
public async Task<IActionResult> UpdateUser([FromBody] UpdateUserDTO userDTO)
@ -83,10 +59,6 @@ namespace API.Controllers
return await _userLogic.EditProfile(userDTO, userId);
}
/// <summary>
/// Deletes the user
/// </summary>
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpDelete("delete")]
public async Task<IActionResult> DeleteUser()
@ -97,11 +69,6 @@ namespace API.Controllers
return await _userLogic.DeleteUser(userId);
}
/// <summary>
/// For when the jwt token is outdated
/// </summary>
/// <param name="refreshToken">contains a string with the refreshtoken</param>
/// <returns>returns a new refreshtoken and new jwt token</returns>
[HttpPost("refreshtoken")]
public async Task<IActionResult> RefreashToken([FromBody] RefreshTokenDTO refreshToken)
{