public Application Apply(Applicant.Applicant applicant) { if (!IsOpen) { throw new ValidationException("It's not possible to apply to a closed opening."); } return(new Application(applicant.Id, Id)); }
public async Task <Application> ApplyToOpening(Applicant.Applicant applicant, Opening opening) { if (await _applicationRepository.HasAlreadyApplied(applicant, opening)) { throw new ValidationException("You already applied to this opening."); } var application = opening.Apply(applicant); await _applicationRepository.CreateAsync(application); return(application); }