예제 #1
0
        public IHttpActionResult AddStudentToWaitingList(int courseID, StudentViewModel student)
        {
            try
            {
                _service.AddStudentToWaitingList(courseID, student);
            }
            catch (AppObjectNotFoundException)
            {
                return(NotFound());
            }
            catch (DuplicateCourseRegistrationException)
            {
                return(StatusCode(HttpStatusCode.PreconditionFailed));
            }

            return(StatusCode(HttpStatusCode.OK)); //Should return OK according to the tester..
        }
예제 #2
0
 public IHttpActionResult AddStudentToWaitingList(int id, [FromBody] AddStudentViewModel student)
 {
     try
     {
         return(Content(HttpStatusCode.OK, _service.AddStudentToWaitingList(id, student)));
     }
     catch (NotFoundException)
     {
         return(StatusCode(HttpStatusCode.NotFound));
     }
     catch (PreconditionFailedException)
     {
         return(StatusCode(HttpStatusCode.PreconditionFailed));
     }
     catch (DbException)
     {
         return(InternalServerError());
     }
 }
예제 #3
0
 public IHttpActionResult AddToWaitinglist(int id, AddStudentViewModel model)
 {
     try
     {
         _service.AddStudentToWaitingList(id, model.SSN);
         return(Ok());
     }
     catch (AlreadyRegisteredException)
     {
         return(StatusCode(HttpStatusCode.PreconditionFailed));
     }
     catch (WaitingListException)
     {
         return(StatusCode(HttpStatusCode.PreconditionFailed));
     }
     catch (AppObjectNotFoundException)
     {
         return(NotFound());
     }
 }