From 0d2ac9af37fc4ec611a6dc3c9c4162a0aa7af09a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 14 May 2019 09:53:48 +0200 Subject: [PATCH] refactored code --- .../util/CacheConstructionUtil.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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)); }