class GrantOfferLetterController {

    @PreAuthorize("hasPermission(#projectId, 'org.innovateuk.ifs.project.resource.ProjectCompositeId', 'ACCESS_GRANT_OFFER_LETTER_SEND_SECTION')")
    @PostMapping("/send")
    public String sendGrantOfferLetter(@P("projectId") @PathVariable Long projectId,
                                       Model model,
                                       @ModelAttribute(FORM_ATTR) @Valid GrantOfferLetterLetterForm form,
                                       @SuppressWarnings("unused") BindingResult bindingResult,
                                       ValidationHandler validationHandler) {
        Supplier<String> failureView = () -> doViewGrantOfferLetterSend(projectId, model, form);

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

            ServiceResult<Void> generateResult = grantOfferLetterService.sendGrantOfferLetter(projectId);

            return validationHandler.addAnyErrors(generateResult).failNowOrSucceedWith(failureView, () ->
                    redirectToGrantOfferLetterPage(projectId));
        });

    }

}