public async Task <Dto> AddExperience <Dto>(ulong primaryKey, CreateExperienceDto createExperienceDto) { Candidate candidate = null; try { candidate = _repository.GetAll().Where(candidate => candidate.Id == primaryKey).Include(candidate => candidate.Experience).Single(); } finally { if (candidate == null) { throw new Exception($"A candidate with id \"{primaryKey}\" was not found."); } } Experience experience = _mapper.Map <Experience>(createExperienceDto); experience.IdCandidate = candidate.Id; candidate.Experience.Add(experience); candidate = await _repository.Update(candidate); Dto mappedExperience = _mapper.Map <Dto>(experience); return(mappedExperience); }
public async Task <IActionResult> CreateExperience([FromBody] CreateExperienceDto createExperienceDto) { var createExperienceCommand = new CreateExperienceCommand(createExperienceDto.CompanyName, createExperienceDto.Position); await _commandBus.SendAsync(createExperienceCommand); return(new JsonResult($"Processed command '{createExperienceCommand}'.")); }
public async Task <ExperienceDto> CreateExperienceAsync(CreateExperienceDto input) { var experience = ObjectMapper.Map <Experience>(input); experience = await _experienceRepo.InsertAsync(experience); await CurrentUnitOfWork.SaveChangesAsync(); return(ObjectMapper.Map <ExperienceDto>(experience)); }
public async Task <IActionResult> CreateExperience(CreateExperienceDto experience) { string experiencesEndPoint = _apiUrls.API + _apiUrls.Experiences; var profileId = User.Claims.First(x => x.Type == UserClaims.ProfileId).Value; experience.ProfileId = Guid.Parse(profileId); var content = new StringContent(JsonConvert.SerializeObject(experience), Encoding.UTF8, "application/json"); var responseExperience = await _oplevOgDelService.Client.PostAsync(experiencesEndPoint, content); if (responseExperience.IsSuccessStatusCode) { var getId = await responseExperience.Content.ReadAsAsync <ExperienceDto>(); return(Redirect($"/{_apiUrls.Experiences}/{getId.Id}")); } return(View()); }
public async Task <IActionResult> Create(CreateExperienceDto input) { var newExperience = await _experienceAppService.CreateExperienceAsync(input); return(CreatedAtRoute("GetExperience", new { id = newExperience.Id }, newExperience)); }