public IHttpActionResult UpdateStudent(int id, Student student) { studentsService = new StudentsService(); // check if student exists in db.students bool studentExistsInDb = studentsService.CheckIfStudentExistsById(id); if (!studentExistsInDb) { return(NotFound()); } // if exists update his name in db.students and db.unistudents Student updatedStudent = studentsService.UpdateStudent(id, student); if (updatedStudent == null) { return(BadRequest()); } studentToExposeService = new StudentToExposeService(); StudentToExpose studentToExpose = studentToExposeService.TrimStudent(student); return(Ok(studentToExpose)); }