public async Task <ResumeDto> Handle( UpdateResumeForLoggedApplicantCommand request, CancellationToken cancellationToken ) { var loggedPerson = await _personRepository.GetLoggedPerson(); if (loggedPerson is null) { throw new ValidationException("The current logged user is not a person."); } var applicant = await _applicantRepository.GetApplicantFromPerson(loggedPerson.Id); Resume resume = new(request.Resume.Introduction !, new Experiences( request.Resume.Experiences?.Select( e => new Experience( e.Company !, e.Description !, new OpenEndedPeriod(e.PeriodStartDate, e.PeriodEndDate) ) ) ! )); if (applicant is null) { applicant = new Domain.Applicant.Applicant(loggedPerson, resume); await _applicantRepository.CreateAsync(applicant, cancellationToken); } else { applicant.ChangeResume(resume); await _applicantRepository.UpdateAsync(applicant, cancellationToken); } return(request.Resume); }
public async Task <Applicant> CreateApplicant(Applicant applicant) { var newApplicant = await _repository.CreateAsync(applicant); return(newApplicant); }