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.. }
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()); } }
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()); } }