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

A possible solution was added

parent 086b833d
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.unprocessableEntity().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