コード例 #1
0
 public IActionResult AddStudentToCourse(int courseID, [FromBody] StudentLiteDTO student)
 {
     try
     {
         _service.AddStudentToCourse(courseID, student.SSN);
         return(Ok());
     } catch (AppObjectNotFoundException e) {
         return(NotFound(e.message));
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
     }
 }