From 165aee2ece417ff506355552d4867873f9019b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20K=C3=BCck?= Date: Wed, 9 Oct 2024 10:42:37 +0200 Subject: [PATCH] PMT-15: Added a deleteProject by ID method --- src/main/java/de/hmmh/pmt/ApiController.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/de/hmmh/pmt/ApiController.java b/src/main/java/de/hmmh/pmt/ApiController.java index 5031841..bc05059 100644 --- a/src/main/java/de/hmmh/pmt/ApiController.java +++ b/src/main/java/de/hmmh/pmt/ApiController.java @@ -35,6 +35,16 @@ public class ApiController implements DefaultApi { return Optional.empty(); } + @Override + public ResponseEntity deleteProject(Long id) { + if (!projectRepository.existsById(id)) { + return ResponseEntity.notFound().build(); + } + + projectRepository.deleteById(id); + return ResponseEntity.noContent().build(); + } + @Override public ResponseEntity getAllProjects() { GetAllProjectsDTO response = new GetAllProjectsDTO();