public IActionResult Post(ProfessorResgistrarDTO professorResgistrarDTO) { var professor = _mapper.Map <Professor>(professorResgistrarDTO); _repo.Add(professor); if (_repo.SaveChanges()) { return(Created($"/api/aluno/{professorResgistrarDTO.Id}", _mapper.Map <AlunoDTO>(professor))); } return(BadRequest("Professor não cadastrado!")); }
public IActionResult Put(int id, ProfessorResgistrarDTO professorResgistrarDTO) { var professor = _repo.GetProfessorById(id); if (professor == null) { return(BadRequest("professor não encontrado!")); } _mapper.Map(professorResgistrarDTO, professor); _repo.Update(professor); if (_repo.SaveChanges()) { return(Created($"/api/aluno/{professorResgistrarDTO.Id}", _mapper.Map <AlunoDTO>(professor))); } return(BadRequest("Professor não atualizado!")); }