diff options
| author | benal01 <bja4245@rit.edu> | 2025-02-16 14:45:58 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-16 14:45:58 -0500 | 
| commit | a9aa3437f736255ec15bab687b26427079dc8429 (patch) | |
| tree | d58a3acb97427e71827ec14b9130ee84b913addf /ufund-api | |
| parent | 2ba5b4564fe3241c2f7213efdaca5285a39507c2 (diff) | |
| parent | 2f4119f80731b62fce2eeff5f1c1dc77ae53c180 (diff) | |
| download | JellySolutions-a9aa3437f736255ec15bab687b26427079dc8429.tar.gz JellySolutions-a9aa3437f736255ec15bab687b26427079dc8429.tar.bz2 JellySolutions-a9aa3437f736255ec15bab687b26427079dc8429.zip  | |
Merge pull request #3 from RIT-SWEN-261-02/update-need
Update need
Diffstat (limited to 'ufund-api')
| -rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java | 17 | ||||
| -rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java | 4 | 
2 files changed, 17 insertions, 4 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 106b2e0..8d394c1 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 @@ -40,9 +40,22 @@ public class CupboardController {          return cupboard.getNeed(id);      } + +    /** +     * Updates a Need with the provided one +     * +     * @param need The need to update +     * @return OK response and the need if it was successful, or INTERNAL_SERVER_ERROR if there was an issue +     */ +      @PutMapping("") -    public void updateNeed(@RequestBody Need need) { -        cupboard.updateNeed(need); +    public ResponseEntity<Need> updateNeed(@RequestBody Need need) { +        try { +            need = cupboard.updateNeed(need); +            return new ResponseEntity<>(need, HttpStatus.OK); +        } catch (IOException e) { +            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); +        }      }      @DeleteMapping("/{id}") diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java index a626561..0ce015c 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/model/Cupboard.java @@ -23,8 +23,8 @@ public class Cupboard {          return dao.findNeeds(name);      } -    public void updateNeed(Need need) throws IOException { -        dao.updateNeed(need); +    public Need updateNeed(Need need) throws IOException { +        return dao.updateNeed(need);      }      public void removeNeed(int id) throws IOException {  | 
