class AssignQuestionController {

    @PostMapping("/question/{questionId}/assign")
    public String assign(@Valid @ModelAttribute("form") AssignQuestionForm form,
                         @SuppressWarnings("unused") BindingResult bindingResult,
                         ValidationHandler validationHandler,
                         @PathVariable("questionId") long questionId,
                         @PathVariable("applicationId") long applicationId,
                         HttpServletRequest request,
                         HttpServletResponse response,
                         Model model,
                         UserResource loggedInUser) {
        Supplier<String> failureView = () -> doViewAssignPage(model, questionId, applicationId);
        ProcessRoleResource assignedBy = userRestService.findProcessRole(loggedInUser.getId(), applicationId).getSuccess();
        return validationHandler.failNowOrSucceedWith(failureView, () -> {
            ServiceResult<Void> assignResult = questionService.assign(questionId, applicationId, form.getAssignee(), assignedBy.getId());

            return validationHandler.addAnyErrors(assignResult)
                    .failNowOrSucceedWith(failureView, () -> redirectToRelevantPage(applicationId, questionId, request, response));
        });
    }

}