class RepositoryApplicationService implements ApplicationService {

    @Override
    @Transactional
    public ProjectApplication createApplicationForUser(User user, String projectId, String comment) {
        var project = projectService.getProjectById(projectId);
        var projectStatus = project.getStatus().toLowerCase();

        if(userHasAppliedForProject(user, project)) {
            throw new AlreadyAppliedException();
        }

        if(applicationsForbiddenStatus.contains(projectStatus)) {
            throw new ProjectStatusPreventsApplicationException();
        }

        // use a clock for testing
        var applicationDate = LocalDateTime.now(clock);
        var application = new ProjectApplication(project, comment, user, applicationDate);

        var savedApplication = applicationRepo.save(application);
        applicationEventHandler.onApplicationReceived(savedApplication);

        return savedApplication;
    }

    @Autowired public  RepositoryApplicationService(ProjectService projectService,
                                        ProjectApplicationRepository applicationRepo,
                                        ProjectApplicationEventHandler applicationEventHandler,
                                        Clock clock,
                                        ProjectBoardConfigurationProperties properties);

}