diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java index bdbe78c..59e6db1 100644 --- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java +++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java @@ -324,6 +324,32 @@ public class Controller { return createCacheUtil(cache); } + @RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json") + @ResponseBody + public ResponseEntity editCache(@RequestBody Cache newCache){ + + //---------------------- + //Get Cache + ResponseEntity getCache = FinderUtil.findCacheById(newCache.getId() + ""); + + if (getCache.getStatusCodeValue() != 200) { + return getCache; + } + + Cache oldCache = (Cache) getCache.getBody(); + //---------------------- + + oldCache.setDescription(newCache.getDescription()); + oldCache.setName(newCache.getName()); + oldCache.setRankingPoints(newCache.getRankingPoints()); + oldCache.setReward(newCache.getReward()); + oldCache.setStationen(newCache.getStationen()); + + cacheRepository.save(oldCache); + + return ResponseEntity.status(200).body("Cache edited"); + } + @ApiOperation(value = "Checks if the given User has an admin role") @ApiResponses(value = { @ApiResponse(code = 404, message = "Database error"),