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()) {