diff options
Diffstat (limited to 'ufund-api/src/main/java')
| -rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java | 15 | 
1 files changed, 13 insertions, 2 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java index 75dcc7e..1fdd435 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java @@ -20,9 +20,20 @@ public class CupboardController {      private ArrayList<Need> needs;      private Cupboard cupboard; +    /** +     * Creates a Need with the provided object +     * +     * @param need The need to create +     * @return OK response and the need if it was successful, INTERNAL_SERVER_ERROR otherwise +     */      @PostMapping("") -    public void createNeed(@RequestBody Need need) { -        cupboard.createNeed(need); +    public ResponseEntity<Need> createNeed(@RequestBody Need need) { +        try { +            cupboard.createNeed(need); +            return new ResponseEntity<>(need, HttpStatus.OK); +        } catch (IOException ex) { +            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); +        }      }      @GetMapping("")  | 
