class InterviewApplicationSendInviteController {

    @PostMapping("/send")
    public String sendInvites(Model model,
                              @PathVariable("competitionId") long competitionId,
                              @ModelAttribute("form") @Valid InterviewApplicationSendForm form,
                              BindingResult bindingResult,
                              ValidationHandler validationHandler) {

        Supplier<String> failureView = () -> getInvitesToSend(model, competitionId, 0, form, bindingResult);
        return validationHandler.failNowOrSucceedWith(failureView, () -> {
            RestResult<Void> sendResult = interviewAssignmentRestService
                    .sendAllInvites(competitionId, new AssessorInviteSendResource(form.getSubject(), form.getContent()));

            return validationHandler.addAnyErrors(error(removeDuplicates(sendResult.getErrors())))
                    .failNowOrSucceedWith(failureView, () -> redirectToStatusTab(competitionId));
        });
    }

    @Autowired public  InterviewApplicationSendInviteController(InterviewApplicationsSendModelPopulator interviewApplicationsSendModelPopulator,
                                                    InterviewApplicationSentInviteModelPopulator interviewApplicationSentInviteModelPopulator,
                                                    InterviewAssignmentRestService interviewAssignmentRestService);

}