@RequestMapping(
      value = "/submitEdited/delete",
      method = {RequestMethod.POST},
      headers = "Accept=*/*",
      produces = "application/json")
  public @ResponseBody String delete(@RequestBody PropertyDeleteJson propertyToDeleteJson) {

    Long idToDelete = propertyToDeleteJson.getPropertyId();
    Property propertyToDelete = new Property();
    try {
      propertyToDelete = propertyDao.findPropertyById(idToDelete);
      List<PropertyOwner> owners = propertyToDelete.getPropertyOwners();
      List<Utility> utilities = propertyToDelete.getPropertyUtilities();
      List<Photo> photos = propertyToDelete.getPropertyPhotos();
      owners.clear();
      utilities.clear();
      photos.clear();
      propertyDao.delete(idToDelete);
    } catch (DBException e) {
      System.out.println("Error!");
    }
    String message = "";
    if (idToDelete != null) {
      message = "Property Nr." + idToDelete + " was deleted successfully!";
    }

    return message;
  }
  @RequestMapping(
      value = "deleteProperty/delete/{ID}",
      method = {RequestMethod.GET},
      headers = "Accept=*/*",
      produces = "application/json") // Ajax controller
  public @ResponseBody ModelAndView execute2(
      @PathVariable(value = "ID") Long ID, HttpServletRequest request) {
    HttpSession session = request.getSession();
    String userName = (String) session.getAttribute("userName");
    String userPassword = (String) session.getAttribute("userPassword");
    User user = new User();
    List<Property> clientProperties = new ArrayList<>();

    Property propertyToDelete = new Property();

    String message = "";

    try {
      propertyToDelete = propertyDao.findPropertyById(ID);
      List<PropertyOwner> owners = propertyToDelete.getPropertyOwners();
      List<Utility> utilities = propertyToDelete.getPropertyUtilities();
      List<Photo> photos = propertyToDelete.getPropertyPhotos();
      owners.clear();
      utilities.clear();
      photos.clear();
      propertyDao.delete(ID);
      message = "Property Nr." + ID + " deleted successfully!";
      user = userDao.findUserByCredentials(userName, userPassword);
      if (user != null) {
        clientProperties = propertyDao.findPropertyByClient(user);
        user.setListOfProperties(clientProperties);
      }
    } catch (DBException e) {
      System.out.println("Error!");
    }

    List<Property> propertiesOfThisUser = user.getListOfProperties();
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("model", propertiesOfThisUser);
    modelAndView.addObject("message", message);
    modelAndView.setViewName("/deleteSpecificProperty");

    return modelAndView;
  }
 @RequestMapping(
     value = "deleteProperty/{ID}",
     method = {RequestMethod.GET},
     headers = "Accept=*/*",
     produces = "application/json") // Ajax controller
 public @ResponseBody Property execute1(@PathVariable(value = "ID") Long ID) { // ID-property id;
   // a.k.a. seeDetails of property which we want to delete;
   Property prop = new Property();
   try {
     prop = propertyDao.findPropertyById(ID);
   } catch (DBException e) {
     System.out.println("Error!");
   }
   return prop;
 }
  @RequestMapping(
      value = "deleteProperty",
      method = {RequestMethod.GET}) // Ajax controller
  public ModelAndView execute(HttpServletRequest request) {

    HttpSession session = request.getSession();
    String userName = (String) session.getAttribute("userName");
    String userPassword = (String) session.getAttribute("userPassword");
    User user = new User();
    List<Property> clientProperties = new ArrayList<>();
    try {
      user = userDao.findUserByCredentials(userName, userPassword);
      if (user != null) {
        clientProperties = propertyDao.findPropertyByClient(user);
        user.setListOfProperties(clientProperties);
      }
    } catch (DBException e) {
      System.out.println("Error!");
    }

    List<Property> propertiesOfThisUser = user.getListOfProperties();
    return new ModelAndView("deleteSpecificProperty", "model", propertiesOfThisUser);
  }