class ProjectTeamController {

    @PostMapping(params = "invite-to-project")
    @PreAuthorize("hasAnyAuthority('ifs_administrator', 'support')")
    @SecuredBySpring(value = "EDIT_PROJECT_TEAM", description = "IFS Admin and support users can edit project team.")
    public String inviteToProject(@Valid @ModelAttribute("form") ProjectTeamForm form,
                                  BindingResult bindingResult,
                                  ValidationHandler validationHandler,
                                  @PathVariable long projectId,
                                  @PathVariable long competitionId,
                                  @RequestParam("invite-to-project") long organisationId,
                                  Model model,
                                  UserResource loggedInUser) {
        Supplier<String> failureView = () -> {
            model.addAttribute("model", projectTeamPopulator.populate(projectId, loggedInUser)
                    .openAddTeamMemberForm(organisationId));
            return "projectteam/project-team";
        };

        Supplier<String> successView = () -> format("redirect:/competition/%d/project/%d/team", competitionId, projectId);

        return projectInviteHelper.sendInvite(form.getName(), form.getEmail(), loggedInUser, validationHandler,
                failureView, successView, projectId, organisationId);
    }

}