Ejemplo n.º 1
0
  /**
   * Deletes an Area if the currently logged in user is the owner of the Area.
   *
   * @param areaid which area will be deleted
   * @param whoIsLoggedIn to check who is logged in
   * @return true if deletion was successful, false if not
   */
  public boolean deleteArea(Long areaid, Person whoIsLoggedIn) {

    if (areaRepository.exists(areaid)) {

      Area area = areaRepository.findOne(areaid);
      if (area.getOwner().getId() == whoIsLoggedIn.getId()) {
        if (findAreaById(areaid).getElements().isEmpty()) {
          areaRepository.delete(areaid);
          return true;
        }
      }
      return false;
    }
    return false;
  }
Ejemplo n.º 2
0
 public Area findAreaById(Long id) {
   return areaRepository.findOne(id);
 }