class ProjectManagerController {

    @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_PROJECT_MANAGER_PAGE')")
    @PostMapping(value = "/{projectId}/team/project-manager")
    public String updateProjectManager(@PathVariable("projectId") final long projectId, Model model,
                                       @Valid @ModelAttribute("form") ProjectManagerForm projectManagerForm,
                                       @SuppressWarnings("unused") BindingResult bindingResult, ValidationHandler validationHandler,
                                       UserResource loggedInUser) {
        Supplier<String> failureView = () -> doViewProjectManager(model, projectId, loggedInUser);

        return validationHandler.failNowOrSucceedWith(failureView, () -> {

            ServiceResult<Void> updateResult = projectDetailsService.updateProjectManager(projectId, projectManagerForm.getProjectManager());

            return validationHandler.addAnyErrors(updateResult, toField("projectManager")).
                    failNowOrSucceedWith(failureView, () -> redirectToProjectTeamPage(projectId));
        });
    }

    public  ProjectManagerController(
            ProjectService projectService,
            ProjectDetailsService projectDetailsService
    );

}