Skip to content
Snippets Groups Projects

WeekMenu backend api

Merged Axel Ytterås requested to merge recipe-by-ingredient into main
24 files
+ 1301
50
Compare changes
  • Side-by-side
  • Inline
Files
24
@@ -54,7 +54,7 @@ public class FridgeController {
@@ -54,7 +54,7 @@ public class FridgeController {
* HTTP 200 OK - ingredients added to fridge
* HTTP 200 OK - ingredients added to fridge
* HTTP 404 Not found - if account or fridge were not found
* HTTP 404 Not found - if account or fridge were not found
*
*
* @param ingredientList
* @param ingredientList the ingredient list
* @return ingredient list
* @return ingredient list
*/
*/
@PostMapping("")
@PostMapping("")
@@ -84,6 +84,7 @@ public class FridgeController {
@@ -84,6 +84,7 @@ public class FridgeController {
Account loggedInAccount = accountRepository.findByEmail(authenticatedUsername).orElseThrow();
Account loggedInAccount = accountRepository.findByEmail(authenticatedUsername).orElseThrow();
Item item = itemRepository.findById(request.itemId()).orElseThrow();
Item item = itemRepository.findById(request.itemId()).orElseThrow();
Ingredient ingredient = new Ingredient(item, request.amount());
Ingredient ingredient = new Ingredient(item, request.amount());
 
ingredient.setStatus(Ingredient.Status.FREE);
Ingredient newIngredient = ingredientRepository.save(ingredient);
Ingredient newIngredient = ingredientRepository.save(ingredient);
List<Ingredient> ingredientList = new ArrayList<>();
List<Ingredient> ingredientList = new ArrayList<>();
ingredientList.add(newIngredient);
ingredientList.add(newIngredient);
Loading