Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IDATT2106 Scrum Team 02
Backend
Merge requests
!29
Add to fridge from shopping list
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add to fridge from shopping list
AddToFridgeFromShoppingList
into
main
Overview
0
Commits
4
Pipelines
1
Changes
3
Merged
Axel Ytterås
requested to merge
AddToFridgeFromShoppingList
into
main
2 years ago
Overview
0
Commits
4
Pipelines
1
Changes
3
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
d66309a0
4 commits,
2 years ago
3 files
+
19
−
22
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/main/java/edu/ntnu/idatt210602/matsvinnbackend/controller/ShoppingListController.java
+
4
−
4
Options
@@ -221,18 +221,18 @@ public class ShoppingListController {
@@ -221,18 +221,18 @@ public class ShoppingListController {
/**
/**
* Method to buy a list of ingredients from the shopping list, putting them in fridge
* Method to buy a list of ingredients from the shopping list, putting them in fridge
* @param ingredient
Id
s a list of ingredient
id
s
* @param ingredients a list of ingredients
* @return the updated shopping list
* @return the updated shopping list
*/
*/
@ResponseStatus
(
code
=
HttpStatus
.
OK
)
@ResponseStatus
(
code
=
HttpStatus
.
OK
)
@
Delete
Mapping
(
"/purchased"
)
@
Put
Mapping
(
"/purchased"
)
public
@ResponseBody
ShoppingList
buyIngredients
(
@RequestBody
List
<
In
teger
>
ingredient
Id
s
)
{
public
@ResponseBody
ShoppingList
buyIngredients
(
@RequestBody
List
<
In
gredient
>
ingredients
)
{
String
authenticatedUsername
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
();
String
authenticatedUsername
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
();
Account
loggedInAccount
=
accountRepository
.
findByEmail
(
authenticatedUsername
).
orElseThrow
();
Account
loggedInAccount
=
accountRepository
.
findByEmail
(
authenticatedUsername
).
orElseThrow
();
try
{
try
{
return
shoppingListService
.
buyAll
(
ingredient
Id
s
,
loggedInAccount
);
return
shoppingListService
.
buyAll
(
ingredients
,
loggedInAccount
);
}
catch
(
IllegalArgumentException
e
)
{
}
catch
(
IllegalArgumentException
e
)
{
throw
new
ResponseStatusException
(
HttpStatus
.
NOT_FOUND
,
e
.
getMessage
());
throw
new
ResponseStatusException
(
HttpStatus
.
NOT_FOUND
,
e
.
getMessage
());
}
catch
(
IllegalStateException
e
)
{
}
catch
(
IllegalStateException
e
)
{
Loading