public IActionResult CreateOrUpdate(CandidateCreateModel model) { if (ModelState.IsValid) { if (model.Foto != null) { var uniqueFileName = GetUniqueFileName(model.Foto.FileName); var uploads = Path.Combine(appEnvironment.WebRootPath, "uploads"); var filePath = Path.Combine(uploads, uniqueFileName); model.Foto.CopyTo(new FileStream(filePath, FileMode.Create)); model.FotoURL = filePath; } var entity = mapper.Map <Candidate>(model); foreach (var item in model.SkillsId) { var skill = skillManager.Get(item); (entity.Skills as List <Skill>).Add(skill); } entity.Creator = userManager.GetByLogin(User.Identity.Name); if (entity.Id == 0) { candidateManager.Create(entity); } else { candidateManager.Update(entity); } } return(RedirectToAction("Index", "Home")); }
///<inheritdoc/> public CandidateDTO Update(UpdateCandidateDTO updateCandidateDTO) { var candidate = candidateManager.Get(updateCandidateDTO.Id); candidate.Firstname = updateCandidateDTO.Firstname; candidate.Secondname = updateCandidateDTO.Secondname; candidate.Patronimic = updateCandidateDTO.Patronimic; candidate.Experience = updateCandidateDTO.Experience; candidate.ProfessionalField = updateCandidateDTO.ProfessionalField; candidate.Skills = updateCandidateDTO.Skills; candidate.Photo = updateCandidateDTO.Photo; var entity = candidateManager.Update(candidate); return(mapper.Map <CandidateDTO>(entity)); }
public IActionResult Put([FromBody] CandidateDTO candidateDto) { _candidateManager.Update(candidateDto); return(Ok()); }