From d5ca26bbd33b34a5811b83c484e537f06a25e3d0 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Mar 2019 21:51:00 +0100 Subject: [PATCH] =?UTF-8?q?startCache=20wurde=20aufgrund=20des=20neuen=20A?= =?UTF-8?q?ttributs=20station=20in=20der=20bearbeitet-Tabelle=20=C3=BCbera?= =?UTF-8?q?rbeitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../labsw/bugageocaching/controller/Controller.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index b0b29d6..4cdf7fc 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -69,7 +69,8 @@ public class Controller { @RequestMapping("/api/startCache") public @ResponseBody String startCache(@RequestParam(value = "userID", defaultValue = "-1") String userID, - @RequestParam String cacheID) throws IllegalParameterException { + @RequestParam String cacheID, + @RequestParam String stationID) throws IllegalParameterException { if (!userID.equals("-1")) { // ein angemeldeter user startet den cache(es werden zwei parameter übergeben) @@ -91,6 +92,14 @@ public class Controller { throw new IllegalParameterException("There is no cache with the ID " + cacheID); } + Optional stationOptional = stationRepository.findById(Integer.valueOf(stationID)); + if (stationOptional.isPresent()) { + Station station = stationOptional.get(); + bearbeitet.setAktuelleStation(station); + } else { + throw new IllegalParameterException("There is no station with the ID " + stationID); + } + Optional cacheAccesDefinitionOptional = cacheAccesDefinitionRepository.findById(1); // bearbeitet if (cacheAccesDefinitionOptional.isPresent()) {