public StudentSubjectToExpose TrimStudentSubject(StudentSubject studentSubject) { StudentSubjectToExpose studentSubjectToExpose = new StudentSubjectToExpose() { StudentSubjectID = studentSubject.StudentSubjectID, SubjectID = studentSubject.SubjectID, StudentID = studentSubject.StudentID, grade = studentSubject.Grade }; return(studentSubjectToExpose); }
// GET /api/students/id public IHttpActionResult GetStudentSubject(int id) { studentSubjectsService = new StudentSubjectsService(); studentSubjectToExposeService = new StudentSubjectToExposeService(); StudentSubject studentSubject = studentSubjectsService.GetStudentSubject(id); if (studentSubject == null) { return(NotFound()); } // turn student subject into studentsubject to expose StudentSubjectToExpose studentSubjectToExpose = studentSubjectToExposeService .TrimStudentSubject(studentSubject); return(Ok(studentSubjectToExpose)); }
public List <StudentSubjectToExpose> TrimStudentSubjects(List <StudentSubject> studentSubjects) { List <StudentSubjectToExpose> studentSubjectsToExpose = new List <StudentSubjectToExpose>(); foreach (StudentSubject studentSubject in studentSubjects) { StudentSubjectToExpose studentSubjectToExpose = new StudentSubjectToExpose() { StudentSubjectID = studentSubject.StudentSubjectID, SubjectID = studentSubject.SubjectID, StudentID = studentSubject.StudentID, grade = studentSubject.Grade + 1 }; studentSubjectsToExpose.Add(studentSubjectToExpose); } return(studentSubjectsToExpose); }
public IHttpActionResult UpdateStudentSubject(int id, StudentSubject studentSubject) { studentSubjectsService = new StudentSubjectsService(); studentSubjectToExposeService = new StudentSubjectToExposeService(); StudentSubject theStudentSubject = new StudentSubject(); theStudentSubject.Grade = studentSubject.Grade; StudentSubject newStudentSubject = studentSubjectsService .UpdateStudentService(id, studentSubject); if (newStudentSubject == null) { return(BadRequest()); } StudentSubjectToExpose newStudentSubjectToExpose = studentSubjectToExposeService .TrimStudentSubject(newStudentSubject); return(Ok(newStudentSubjectToExpose)); }