예제 #1
0
  /** Get Spa by Id */
  @Transactional
  public AppResponse<Spa> getSpaById(Integer id) {
    Spa spa = null;
    AppResponse<Spa> appResponse = new AppResponse<Spa>();
    appResponse.setCode(EventStatus.failure.getValue());
    try {
      spa = (Spa) spaDao.readById(id);
      // TODO: increase the editprofile page access count for this accoutant.
      // I am assuming this call has come from the editprofile page.
      // This is completely wrong. But I still am doing this because giving something to the
      // customers is more
      // important to me than getting it 100% right! For the sake of time.
      spa.setNoOfVisitToEditProfilepage(spa.getNoOfVisitToEditProfilepage() + 1);
      // Set the section fill information
      ProfileCompletionStatus profileCompletionStatus = new ProfileCompletionStatus(spa);
      spa.setProfileCompletionStatus(profileCompletionStatus);

      appResponse.setCode(EventStatus.success.getValue());
      appResponse.setData(spa);
      spaDao.update(spa);
    } catch (CommonException e) {
      e.printStackTrace();
      appResponse.setDescription(MessageCollection.ERROR_ENGINEERS_WILL_FIX_IT);
    }

    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;
  }