public IActionResult Insert([FromBody] LecturersDTO dto) { try { var model = mapper.Map <Lecturers>(dto); if (model != null) { repository.Insert(model); var result = repository.SaveChanges(); if (result) { return(Ok()); } } return(NotFound()); } catch (System.Exception msg) { return(NotFound(msg)); } }
public IActionResult Update(string id, [FromBody] LecturersDTO dto) { try { var isExist = repository.GetById(id); if (isExist != null) { mapper.Map(dto, isExist); repository.Update(isExist); var result = repository.SaveChanges(); if (result) { return(Ok()); } } return(NotFound()); } catch (System.Exception msg) { return(NotFound(msg)); } }