app/controllers/DestinationsController.java
@Security.Authenticated(SecureSession.class)
    public CompletionStage<Result> update(Http.Request request, Integer id) {
        Integer userId = SessionController.getCurrentUserId(request);
        Form<Destination> destinationForm = form.bindFromRequest(request);
        String visible = destinationForm.field("visible").value().get();
        int visibility = Integer.parseInt(visible);
        Destination dest = destinationForm.value().get();
        dest.setTravellerTypesStringDest(destinationForm.field("travellerTypesStringDestEdit").value().get());
        if (!dest.getTravellerTypesForm().isEmpty()) {
            dest.initTravellerType();
        } else {
            dest.setTravellerTypes(null);
        }
        dest.setVisible(visibility);
        if (destinationRepository.checkValidEdit(dest, userId, destinationRepository.lookup(id))) {
            return supplyAsync(() -> redirect(destShowRoute).flashing("failure", "This destination is already registered and unavailable to create"));
        }
        if (longLatCheck(dest)) {
            return destinationRepository.update(dest, id).thenApplyAsync(destId -> {
                if (visibility == 1 && destId.isPresent()) {
                    dest.setDestinationId(destId.get());
                    newPublicDestination(dest);
                }
                return redirect(destShowRoute).flashing("success", "Destination: " + dest.getName() + " updated");
            });
        } else {
            return supplyAsync(() -> redirect(destShowRoute).flashing("failure", "A destinations longitude(-180 to 180) and latitude(90 to -90) must be valid"));
        }
    }
/**
     * This method updates destination in the database
     *
     * @param request
     * @param id      The ID of the destination to editDestinations.
     * @return redirect
     */
This method updates destination in the database
@param request
@param id      The ID of the destination to editDestinations.
@return redirect
This method updates destination in the database @param request @param id The ID of the destination to editDestinations . @return redirect
@Security.Authenticated(SecureSession.class)
    public CompletionStage<Result> update(Http.Request request, Integer id) {
        Integer userId = SessionController.getCurrentUserId(request);
        Form<Destination> destinationForm = form.bindFromRequest(request);
        String visible = destinationForm.field("visible").value().get();
        int visibility = Integer.parseInt(visible);
        Destination dest = destinationForm.value().get();
        dest.setTravellerTypesStringDest(destinationForm.field("travellerTypesStringDestEdit").value().get());
        if (!dest.getTravellerTypesForm().isEmpty()) {
            dest.initTravellerType();
        } else {
            dest.setTravellerTypes(null);
        }
        dest.setVisible(visibility);
        if (destinationRepository.checkValidEdit(dest, userId, destinationRepository.lookup(id))) {
            return supplyAsync(() -> redirect(destShowRoute).flashing("failure", "This destination is already registered and unavailable to create"));
        }
        if (longLatCheck(dest)) {
            return destinationRepository.update(dest, id).thenApplyAsync(destId -> {
                if (visibility == 1 && destId.isPresent()) {
                    dest.setDestinationId(destId.get());
                    newPublicDestination(dest);
                }
                return redirect(destShowRoute).flashing("success", "Destination: " + dest.getName() + " updated");
            });
        } 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 > update ( Http . Request request , Integer id ) { Integer userId = SessionController . getCurrentUserId ( request ) ; Form < Destination > destinationForm = form . bindFromRequest ( request ) ; String visible = destinationForm . field ( "visible" ) . value ( ) . get ( ) ; int visibility = Integer . parseInt ( visible ) ; Destination dest = destinationForm . value ( ) . get ( ) ; dest . setTravellerTypesStringDest ( destinationForm . field ( "travellerTypesStringDestEdit" ) . value ( ) . get ( ) ) ; if ( ! dest . getTravellerTypesForm ( ) . isEmpty ( ) ) { dest . initTravellerType ( ) ; } else { dest . setTravellerTypes ( null ) ; } dest . setVisible ( visibility ) ; if ( destinationRepository . checkValidEdit ( dest , userId , destinationRepository . lookup ( id ) ) ) { return supplyAsync ( ( ) -> redirect ( destShowRoute ) . flashing ( "failure" , "This destination is already registered and unavailable to create" ) ) ; } if ( longLatCheck ( dest ) ) { return destinationRepository . update ( dest , id ) . thenApplyAsync ( destId -> { if ( visibility == 1 && destId . isPresent ( ) ) { dest . setDestinationId ( destId . get ( ) ) ; newPublicDestination ( dest ) ; } return redirect ( destShowRoute ) . flashing ( "success" , "Destination: " + dest . getName ( ) + " updated" ) ; } ) ; } else { return supplyAsync ( ( ) -> redirect ( destShowRoute ) . flashing ( "failure" , "A destinations longitude(-180 to 180) and latitude(90 to -90) must be valid" ) ) ; } }
This method updates destination in the database
 @param request
 @param id      The ID of the destination to editDestinations.
This method updates destination in the database @param request @param id The ID of the destination to editDestinations .