public ScheduledExam(Teacher_Exam teacherExam) { if (teacherExam != null) { this.ID = teacherExam.ID; this.DatetimeStart = teacherExam.DatetimeStart; this.DatetimeEnd = teacherExam.DatetimeEnd; this.AvailableTime = teacherExam.AvailableTime; } }
//constructor public TeacherExamDTO(Teacher_Exam teacherExam) { if (teacherExam != null) { this.ID = teacherExam.ID; this.TeacherID = (int)teacherExam.TeacherID; this.ExamID = (int)teacherExam.ExamID; this.DatetimeStart = teacherExam.DatetimeStart; this.DatetimeEnd = teacherExam.DatetimeEnd; this.AvailableTime = teacherExam.AvailableTime; } }
public IHttpActionResult DeleteTeacher_Exam(int id) { Teacher_Exam teacher_Exam = db.Teacher_Exam.Find(id); if (teacher_Exam == null) { return(NotFound()); } db.Teacher_Exam.Remove(teacher_Exam); db.SaveChanges(); return(Ok(teacher_Exam)); }
public IHttpActionResult PutTeacher_Exam(int id, TeacherExamDTO teacherExamDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (teacherExamDTO.ID == null || id != teacherExamDTO.ID) { return(BadRequest()); } Teacher_Exam teacherExam = db.Teacher_Exam.Find(teacherExamDTO.ID); teacherExam.TeacherID = teacherExamDTO.TeacherID; teacherExam.DatetimeStart = teacherExamDTO.DatetimeStart; teacherExam.DatetimeEnd = teacherExamDTO.DatetimeEnd; teacherExam.AvailableTime = teacherExamDTO.AvailableTime; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Teacher_ExamExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostTeacher_Exam(TeacherExamDTO teacherExamDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Teacher_Exam teacherExam = new Teacher_Exam(); if (teacherExamDTO.ID != null) { teacherExam.ID = (int)teacherExamDTO.ID; } teacherExam.TeacherID = teacherExamDTO.TeacherID; teacherExam.ExamID = teacherExamDTO.ExamID; teacherExam.DatetimeStart = teacherExamDTO.DatetimeStart; teacherExam.DatetimeEnd = teacherExamDTO.DatetimeEnd; teacherExam.AvailableTime = teacherExamDTO.AvailableTime; db.Teacher_Exam.Add(teacherExam); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = teacherExamDTO.ID }, teacherExamDTO)); }