app/controllers/DestinationsController.java
@Security.Authenticated(SecureSession.class)
    public CompletionStage<Result> saveDestination(Http.Request request) {
        Integer userId = SessionController.getCurrentUserId(request);
        Form<Destination> destinationForm = form.bindFromRequest(request);
        String visible = destinationForm.field("visible").value().get();
        int visibility = (visible.equals("Public")) ? 1 : 0;
        Destination destination = destinationForm.value().get();
        if (!destination.getTravellerTypesForm().isEmpty()) {
            destination.initTravellerType();
        }
        destination.setProfileId(userId);
        destination.setVisible(visibility);

        if (destinationRepository.checkValidEdit(destination, userId, null)) {
            return supplyAsync(() -> redirect(destShowRoute).flashing("failure", "This destination is already registered and unavailable to create"));
        }
        if (longLatCheck(destination)) {
            return destinationRepository.insert(destination).thenApplyAsync(destId -> {
                if (visibility == 1 && destId.isPresent()) {
                    destination.setDestinationId(destId.get());
                    newPublicDestination(destination);
                }
                return redirect(destShowRoute).flashing("success", "Destination added successfully");
            });
        } else {
            return supplyAsync(() -> redirect(destShowRoute).flashing("failure", "A destinations longitude(-180 to 180) and latitude(90 to -90) must be valid"));
        }
    }
/**
     * Adds a new destination to the database
     *
     * @param request
     * @return redirect
     */
Adds a new destination to the database
@param request
@return redirect
Adds a new destination to the database @param request @return redirect
@Security.Authenticated(SecureSession.class)
    public CompletionStage<Result> saveDestination(Http.Request request) {
        Integer userId = SessionController.getCurrentUserId(request);
        Form<Destination> destinationForm = form.bindFromRequest(request);
        String visible = destinationForm.field("visible").value().get();
        int visibility = (visible.equals("Public")) ? 1 : 0;
        Destination destination = destinationForm.value().get();
        if (!destination.getTravellerTypesForm().isEmpty()) {
            destination.initTravellerType();
        }
        destination.setProfileId(userId);
        destination.setVisible(visibility);
        if (destinationRepository.checkValidEdit(destination, userId, null)) {
            return supplyAsync(() -> redirect(destShowRoute).flashing("failure", "This destination is already registered and unavailable to create"));
        }
        if (longLatCheck(destination)) {
            return destinationRepository.insert(destination).thenApplyAsync(destId -> {
                if (visibility == 1 && destId.isPresent()) {
                    destination.setDestinationId(destId.get());
                    newPublicDestination(destination);
                }
                return redirect(destShowRoute).flashing("success", "Destination added successfully");
            });
        } else {
            return supplyAsync(() -> redirect(destShowRoute).flashing("failure", "A destinations longitude(-180 to 180) and latitude(90 to -90) must be valid"));
        }
    }
@ Security . Authenticated ( SecureSession . class ) public CompletionStage < Result > saveDestination ( Http . Request request ) { Integer userId = SessionController . getCurrentUserId ( request ) ; Form < Destination > destinationForm = form . bindFromRequest ( request ) ; String visible = destinationForm . field ( "visible" ) . value ( ) . get ( ) ; int visibility = ( visible . equals ( "Public" ) ) ? 1 : 0 ; Destination destination = destinationForm . value ( ) . get ( ) ; if ( ! destination . getTravellerTypesForm ( ) . isEmpty ( ) ) { destination . initTravellerType ( ) ; } destination . setProfileId ( userId ) ; destination . setVisible ( visibility ) ; if ( destinationRepository . checkValidEdit ( destination , userId , null ) ) { return supplyAsync ( ( ) -> redirect ( destShowRoute ) . flashing ( "failure" , "This destination is already registered and unavailable to create" ) ) ; } if ( longLatCheck ( destination ) ) { return destinationRepository . insert ( destination ) . thenApplyAsync ( destId -> { if ( visibility == 1 && destId . isPresent ( ) ) { destination . setDestinationId ( destId . get ( ) ) ; newPublicDestination ( destination ) ; } return redirect ( destShowRoute ) . flashing ( "success" , "Destination added successfully" ) ; } ) ; } else { return supplyAsync ( ( ) -> redirect ( destShowRoute ) . flashing ( "failure" , "A destinations longitude(-180 to 180) and latitude(90 to -90) must be valid" ) ) ; } }
Adds a new destination to the database
 @param request
 @return redirect
Adds a new destination to the database @param request @return redirect