Exemplo n.º 1
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;
  }
Exemplo n.º 2
0
  /**
   * And then we go and create the full profile of an spa
   *
   * @param fullName
   * @param email
   * @param phone
   * @param isHidden
   * @return
   */
  @Transactional
  public AppResponse<ProfileCompletionStatus> saveSpaProfile(
      int id,
      String email,
      String firstName,
      String lastName,
      String mobile,
      String businessPhone,
      String city,
      Integer age,
      String area,
      String shortDescription,
      String longDescription,
      String websiteURL,
      String linkedinProfile,
      String fbProfile,
      String gplusProfile,
      Integer yearOfExp,
      String areasOfExpertise,
      String education,
      String certifications,
      String addressLine1,
      String addressLine2,
      String state,
      Integer pincode,
      String country) {
    Spa spa = null;
    // Prepare the response
    AppResponse<ProfileCompletionStatus> appResponse = new AppResponse<ProfileCompletionStatus>();
    appResponse.setCode(EventStatus.failure.getValue());
    // To update the profile the spa must already be created.
    if (id == -1) {
      appResponse.setDescription(
          MessageCollection.ACCOUNTANT_DOES_NOT_EXIST_NEEDED_BEFORE_CREATING_PROFILE);
      return appResponse;
    }

    try {
      spa = (Spa) spaDao.readById(id);
    } catch (CommonException e) {
      e.printStackTrace();
      appResponse.setDescription(MessageCollection.INTERNAL_ERROR_WHILE_ADDING_ACCOUNTANT);
      return appResponse;
    }

    // If the spa is retrieved successfully
    spa.setOwnerFirstName(firstName);
    spa.setOwnerLastName(lastName);
    spa.setPrimaryEmail(email);

    spa.setMobile(mobile);
    spa.setIsProfileCreated(1);
    spa.setIsHidden(0);

    spa.setBusinessPhone1(businessPhone);
    spa.setBusinessPhone2(businessPhone);
    spa.setCity(city);

    spa.setArea(area);

    spa.setShortDescription(shortDescription);
    spa.setLongDescription(longDescription);

    spa.setWebsiteURL(websiteURL);

    spa.setFbProfile(fbProfile);
    spa.setGplusProfile(gplusProfile);

    spa.setAddressLine1(addressLine1);
    spa.setAddressLine2(addressLine2);
    spa.setState(state);
    spa.setPincode(pincode);
    spa.setCountry(country);

    try {
      spaDao.update(spa);
    } catch (CommonException e) {
      e.printStackTrace();
      appResponse.setDescription(MessageCollection.INTERNAL_ERROR_WHILE_ADDING_ACCOUNTANT);
      return appResponse;
    }

    // If spa profile is updated successfully.
    appResponse.setCode(EventStatus.success.getValue());
    appResponse.setData(new ProfileCompletionStatus(spa));
    appResponse.setDescription(MessageCollection.PROFILE_SUCCESSFULLY_UPDATED);

    return appResponse;
  }