Example #1
0
  public ServiceResponse<String> registerUser(RegisterModel model) {
    ServiceResponse<String> response = new ServiceResponse<>();
    response.setStatus(ServiceResponse.Status.SUCCESS);

    if (!userExists(model)) {
      response.setResult(userRepo.registerUser(model));
    } else {
      // user already exists
      response.setStatus(ServiceResponse.Status.FAIL);
      response.setMessage(ServiceResponse.Messages.USER_EXISTS);
    }

    return response;
  }
Example #2
0
  @Override
  public ServiceResponse<UserLocation> updateUserLocation(String userId, UserLocation location) {
    location = userRepo.updateUserLocation(location, userId);

    ServiceResponse<UserLocation> serviceResponse = new ServiceResponse<>();
    if (location != null) {
      serviceResponse.setStatus(ServiceResponse.Status.SUCCESS);
      serviceResponse.setResult(location);
    } else {
      serviceResponse.setStatus(ServiceResponse.Status.FAIL);
      serviceResponse.setMessage(ServiceResponse.Messages.COULD_NOT_UPDATE_USER_LOCATION);
    }

    return serviceResponse;
  }
Example #3
0
  @Override
  public ServiceResponse<String> addJourney(Journey journey, String userId) {
    ServiceResponse<String> response = new ServiceResponse<>();
    response.setStatus(ServiceResponse.Status.SUCCESS);

    if (userExists(userId)) {
      response.setResult(userRepo.addJourney(journey, userId));
    } else {
      // user doesn't exist
      response.setStatus(ServiceResponse.Status.FAIL);
      response.setMessage(ServiceResponse.Messages.USER_NOT_EXISTS);
    }

    return response;
  }
Example #4
0
  @Override
  public ServiceResponse<JourneyUpdate> updateUserJourney(
      String userId, JourneyUpdate journeyUpdate, String journeyId) {
    journeyUpdate = userRepo.updateUserJourney(journeyUpdate, userId, journeyId);

    ServiceResponse<JourneyUpdate> serviceResponse = new ServiceResponse<>();
    if (journeyUpdate != null) {
      serviceResponse.setStatus(ServiceResponse.Status.SUCCESS);
      serviceResponse.setResult(journeyUpdate);
    } else {
      serviceResponse.setStatus(ServiceResponse.Status.FAIL);
      serviceResponse.setMessage(ServiceResponse.Messages.COULD_NOT_UPDATE_USER_LOCATION);
    }

    return serviceResponse;
  }