aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Ferrari <69283684+Sowgro@users.noreply.github.com>2025-02-16 14:51:59 -0500
committerGitHub <noreply@github.com>2025-02-16 14:51:59 -0500
commit865d3d0db661223e446391eb52b824df4858adb3 (patch)
tree748d586b24077cbc2a02753130537d180e761458
parentf420b111c1feedb2e6c4c8a0b3bfb02cfb9449d5 (diff)
parent734128698a92a60c73d00d6aef4e78270c58283a (diff)
downloadJellySolutions-865d3d0db661223e446391eb52b824df4858adb3.tar.gz
JellySolutions-865d3d0db661223e446391eb52b824df4858adb3.tar.bz2
JellySolutions-865d3d0db661223e446391eb52b824df4858adb3.zip
Merge pull request #1 from RIT-SWEN-261-02/create-need
Merge create-need to main
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java15
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("")