class ProjectPartnerController {

    @PostMapping
    public String inviteProjectPartner(@Valid @ModelAttribute(value = "form") ProjectPartnerInviteForm form,
                                       BindingResult bindingResult,
                                       ValidationHandler validationHandler,
                                       @PathVariable long competitionId,
                                       @PathVariable long projectId,
                                       Model model) {
        Supplier<String> success = () -> String.format("redirect:/competition/%d/project/%d/team", competitionId, projectId);
        Supplier<String> failure = () -> inviteProjectPartnerForm(form, bindingResult, projectId, model);

        return validationHandler.failNowOrSucceedWith(failure, () -> {
            validationHandler.addAnyErrors(
                    projectPartnerInviteRestService.invitePartnerOrganisation(projectId, new SendProjectPartnerInviteResource(form.getOrganisationName(), form.getUserName(), form.getEmail())));
            return validationHandler.failNowOrSucceedWith(failure, success);
        });
    }

}