public async Task <Dto> AddEducation <Dto>(ulong primaryKey, CreateEducationDto createEducationDto) { Candidate candidate = null; try { candidate = _repository.GetAll().Where(candidate => candidate.Id == primaryKey).Include(candidate => candidate.Education).Single(); } finally { if (candidate == null) { throw new Exception($"A candidate with id \"{primaryKey}\" was not found."); } } Education education = _mapper.Map <Education>(createEducationDto); education.IdCandidate = candidate.Id; education.Level = education.Level.ToUpper(); candidate.Education.Add(education); candidate = await _repository.Update(candidate); Dto mappedEducation = _mapper.Map <Dto>(education); return(mappedEducation); }
public async Task <EducationDto> CreateEducationAsync(CreateEducationDto input) { var education = ObjectMapper.Map <Education>(input); education = await _educationRepo.InsertAsync(education); await CurrentUnitOfWork.SaveChangesAsync(); return(ObjectMapper.Map <EducationDto>(education)); }
public async Task <IActionResult> Create(CreateEducationDto input) { var newEducation = await _educationAppService.CreateEducationAsync(input); return(CreatedAtRoute("GetEducation", new { id = newEducation.Id }, newEducation)); }