From aacd3e7daa67d8fa30b4d0625b35eadab19e8730 Mon Sep 17 00:00:00 2001 From: Angelina Zhen Date: Sun, 16 Feb 2025 14:35:21 -0500 Subject: Completed Delete Need --- .../ufund/api/ufundapi/controller/CupboardController.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'ufund-api/src/main/java') 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..8fc1d5a 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 @@ -46,8 +46,17 @@ public class CupboardController { } @DeleteMapping("/{id}") - public void deleteNeed(@PathVariable int id) { - cupboard.removeNeed(id); + public ResponseEntity 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); + } } } -- cgit v1.2.3