예제 #1
0
  /**
   * Save spa password. Create an account if spa does not exist.
   *
   * @param id
   * @param password
   * @return
   */
  @Transactional
  public AppResponse<Integer> saveSpaPassword(String email, String password) {
    Spa spa = null;
    AppResponse<Integer> appResponse = new AppResponse<Integer>();
    appResponse.setCode(EventStatus.failure.getValue());
    try {
      spa = (Spa) spaDao.readByEmail(email);
    } catch (CommonException e) {
      e.printStackTrace();
    }
    // If the account is not created first create it.
    if (spa == null) {
      return createSpaWithMinimumParams("", "", email, "", 1, password);
    } else {
      spa.setPassword(password);

      try {
        spaDao.update(spa);
        appResponse.setCode(EventStatus.success.getValue());
        appResponse.setData(spa.getSpaid());
        appResponse.setDescription(MessageCollection.PROFILE_SUCCESSFULLY_UPDATED);
      } catch (CommonException e) {
        e.printStackTrace();
        appResponse.setDescription(MessageCollection.PASSWORD_COULD_NOT_BE_SET);
        return appResponse;
      }
    }

    return appResponse;
  }
예제 #2
0
  /**
   * This method is called first to create an spa in the system. This must be entry point. // *
   *
   * @param firstName
   * @param lastName
   * @param email
   * @param phone
   * @param isHidden
   * @param password
   * @return
   */
  @Transactional
  public AppResponse<Integer> createSpaWithMinimumParams(
      String firstName,
      String lastName,
      String email,
      String phone,
      Integer isHidden,
      String password) {
    AppResponse<Integer> response = new AppResponse<Integer>();
    response.setCode(EventStatus.failure.getValue());
    // Check if the email is not duplicate
    if (doesTheEmailExist(email)) {
      response.setDescription(MessageCollection.THIS_EMAIL_ALREADY_EXISTS);
    }

    Spa spa = new Spa();

    spa.setOwnerFirstName(firstName);
    spa.setOwnerLastName(lastName);
    spa.setPrimaryEmail(email);
    spa.setMobile(phone);
    spa.setJoindate(new java.sql.Date(new java.util.Date().getTime()));
    spa.setIsProfileCreated(0);
    spa.setIsHidden(isHidden);
    spa.setPassword(password);

    spa.setNoOfVisitToEditProfilepage(0);

    Integer spaId = -1;
    try {
      spaId = (Integer) spaDao.save(spa);
      response.setData(spaId);
      response.setCode(EventStatus.success.getValue());
    } catch (CommonException e) {
      e.printStackTrace();
      response.setDescription(MessageCollection.INTERNAL_ERROR_WHILE_ADDING_ACCOUNTANT);
      return response;
    }

    return response;
  }