public async Task <ValidationResult> Handle(AddProfessionalBackgroundCandidateCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { return(message.ValidationResult); } var candidate = await _candidateRepository.GetCandidateWithProfessionalBackground(message.CandidateId); if (candidate == null) { AddError("Candidato Invalido"); return(ValidationResult); } var professionalBackground = new ProfessionalBackground(message.CandidateId, message.JobTitleLevelId, message.WorkingAreaId, message.JobTitleName, message.StartDate, message.EndDate, message.CurrentJob, message.DescriptionJob, message.Company); candidate.AddProfessionalBackground(professionalBackground); _candidateRepository.Update(candidate); return(await SaveChanges(_candidateRepository.UnitOfWork)); }
public async Task AddProfessionalBackground(ProfessionalBackground professionalBackground) { await _context.ProfessionalBackgrounds.AddAsync(professionalBackground); }