class ProjectSpendProfileController {

    private String markSpendProfileComplete(Model model,
                                            final Long projectId,
                                            final Long organisationId,
                                            final String successView,
                                            final UserResource loggedInUser) {
        ServiceResult<Void> result = spendProfileService.markSpendProfileComplete(projectId, organisationId);
        if (result.isFailure()) {
            ProjectSpendProfileViewModel spendProfileViewModel = buildSpendProfileViewModel(projectId, organisationId, loggedInUser);
            spendProfileViewModel.setObjectErrors(Collections.singletonList(new ObjectError(SPEND_PROFILE_CANNOT_MARK_AS_COMPLETE_BECAUSE_SPEND_HIGHER_THAN_ELIGIBLE.getErrorKey(), "Cannot mark as complete, because totals more than eligible")));
            model.addAttribute("model", spendProfileViewModel);
            return BASE_DIR + "/spend-profile";
        } else {
            return successView;
        }
    }

}