Skip to content
Snippets Groups Projects
Commit 698a434b authored by Pedro Pablo Cardona Arroyave's avatar Pedro Pablo Cardona Arroyave
Browse files

Merge branch 'bug-fixing/addTryCatchToAddAllergy' into 'main'

Bug fixing/add try catch to add allergy

See merge request idatt2106-v23-03/backend!151
parents 086b833d 63cbbe6c
No related branches found
No related tags found
No related merge requests found
......@@ -100,9 +100,13 @@ public class UserController {
@PostMapping("/addAllergy")
public ResponseEntity<Boolean> addAllergyToUser(@RequestBody AllergyRequest allergyRequest) {
return userService.addAllergyToUser(allergyRequest.getUsername(), allergyRequest.getAllergyName())
.map(user -> ResponseEntity.ok(user.getAllergies().size() > 0))
.orElseGet(() -> ResponseEntity.notFound().build());
try {
return userService.addAllergyToUser(allergyRequest.getUsername(), allergyRequest.getAllergyName())
.map(user -> ResponseEntity.ok(user.getAllergies().size() > 0))
.orElseGet(() -> ResponseEntity.notFound().build());
}catch (Exception e){
return ResponseEntity.status(409).body(false);
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment