public IActionResult AddStudentToCourse(int courseID, [FromBody] StudentLiteDTO student) { try { _service.AddStudentToCourse(courseID, student.SSN); return(Ok()); } catch (AppObjectNotFoundException e) { return(NotFound(e.message)); } }
public IActionResult AddStudentToCourseWaitingList(int courseID, [FromBody] StudentLiteDTO student) { try { _service.AddStudentToWaitingList(courseID, student.SSN); return(Ok()); } catch (AppObjectNotFoundException e) { return(NotFound(e.Message)); } catch (InvalidParametersException) { var returnCode = new StatusCodeResult(412); return(returnCode); } }
public IActionResult AddStudentToCourse(int courseID, [FromBody] StudentLiteDTO student) { try { var newStudent = _service.AddStudentToCourse(courseID, student.SSN); if (newStudent.Queued == false) { var location = Url.Link("GetStudentsByCourseId", new { id = newStudent.CourseID }); return(Created(location, newStudent.Name + " is now enrolled in the course.")); } else { return(Ok()); } } catch (AppObjectNotFoundException e) { return(NotFound(e.Message)); } catch (InvalidParametersException) { var returnCode = new StatusCodeResult(412); return(returnCode); } }