diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 7dc78ac..0f618b6 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -86,12 +86,12 @@ public class CacheConstructionUtil { return ResponseEntity.status(400).body("station fields can´t be empty"); } - if (station.getLattitude() < 9 || station.getLattitude() > 10) { + if (station.getLongitude() < 9 || station.getLongitude() > 10) { return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees"); } - if (station.getLongitude() < 49 || station.getLongitude() > 50) { - return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees"); + if (station.getLattitude() < 49 || station.getLattitude() > 50) { + return ResponseEntity.status(400).body("Lattitude has to be in the range of 49 to 50 degrees"); } Random r = new Random(); @@ -151,13 +151,6 @@ public class CacheConstructionUtil { } } - for (Station station : oldCache.getStationen()) { - // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht - if (!cache.getStationen().contains(station)) { - stationRepository.delete(station); - } - } - // überprüft den Cache nach validen Daten if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0) { deleteNewCreatedStationsUtil(newCreatedStationList); @@ -185,6 +178,13 @@ public class CacheConstructionUtil { cacheRepository.save(cache); + for (Station station : oldCache.getStationen()) { + // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht + if (!cache.getStationen().contains(station)) { + stationRepository.delete(station); + } + } + return ResponseEntity.status(200).body(new Gson().toJson(cache)); }