From deb50cad9c092bcf4f0e94ab246c2b474e909aa6 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 18 Apr 2019 14:38:20 +0200 Subject: [PATCH] a cache needs atleast 2 stations --- .../labsw/bugageocaching/util/CacheConstructionUtil.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 7acacda..120e077 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -52,11 +52,16 @@ public class CacheConstructionUtil { } // Caches werden in die Datenbank eingetragen - if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0 || cache.getStationen().size() == 0) { + if (cache.getDescription().length() == 0 || cache.getName().length() == 0 || cache.getRankingPoints() == 0.0) { deleteStationenUtil(cache); return ResponseEntity.status(400).body("cache fields can“t be empty"); } + if (cache.getStationen().size() < 2) { + deleteStationenUtil(cache); + return ResponseEntity.status(400).body("a cache needs atleast 2 stations"); + } + for (Cache cache1 : cacheRepository.findAll()) { if (cache1.getName().equals(cache.getName())) { deleteStationenUtil(cache);