class FinanceReviewerServiceImpl extends BaseTransactionalService implements FinanceReviewerService {

    @Override
    @Transactional
    public ServiceResult<Long> assignFinanceReviewer(long financeReviewerUserId, long projectId) {
        return getProjectFinanceUser(financeReviewerUserId)
                .andOnSuccess(user -> getProject(projectId)
                        .andOnSuccessReturn((project) -> {
                            if (project.getFinanceReviewer() != null) {
                                project.getFinanceReviewer().setUser(user);
                                return project.getFinanceReviewer().getId();
                            } else {
                                FinanceReviewer reviewer = financeReviewerRepository.save(new FinanceReviewer(user, project));
                                return reviewer.getId();
                            }
                        }));
    }

}