diff options
| author | Tyler Ferrari <69283684+Sowgro@users.noreply.github.com> | 2025-02-16 14:51:49 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-16 14:51:49 -0500 | 
| commit | f420b111c1feedb2e6c4c8a0b3bfb02cfb9449d5 (patch) | |
| tree | 8fb41ab8be554eb86ebeb8ccfe721259db39d162 | |
| parent | a9aa3437f736255ec15bab687b26427079dc8429 (diff) | |
| parent | aacd3e7daa67d8fa30b4d0625b35eadab19e8730 (diff) | |
| download | JellySolutions-f420b111c1feedb2e6c4c8a0b3bfb02cfb9449d5.tar.gz JellySolutions-f420b111c1feedb2e6c4c8a0b3bfb02cfb9449d5.tar.bz2 JellySolutions-f420b111c1feedb2e6c4c8a0b3bfb02cfb9449d5.zip  | |
Merge pull request #5 from RIT-SWEN-261-02/delete-need
Merge delete-need to main
| -rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java | 13 | 
1 files changed, 11 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 8d394c1..75dcc7e 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 @@ -59,8 +59,17 @@ public class CupboardController {      }      @DeleteMapping("/{id}") -    public void deleteNeed(@PathVariable int id) { -        cupboard.removeNeed(id); +    public ResponseEntity<Need> deleteNeed(@PathVariable int id) { +        try { +            if (cupboard.getNeed(id) != null) { +                cupboard.removeNeed(id); +                return new ResponseEntity<>(HttpStatus.OK); +            } else { +                return new ResponseEntity<>(HttpStatus.NOT_FOUND); +            }  +        } catch (IOException e) { +            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); +        }      }  }  | 
