Пример #1
0
        // 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));
        }
Пример #2
0
        // GET /api/studentssubjects/
        public IHttpActionResult GetStudentSubjects()
        {
            studentSubjectsService        = new StudentSubjectsService();
            studentSubjectToExposeService = new StudentSubjectToExposeService();

            List <StudentSubject> studentSubjects = studentSubjectsService.GetAllStudentSubjects();

            if (studentSubjects.Count() == 0)
            {
                return(NotFound());
            }

            // turn student subjects into studentsubjects to expose
            List <StudentSubjectToExpose> studentSubjectsToExpose = studentSubjectToExposeService
                                                                    .TrimStudentSubjects(studentSubjects);

            return(Ok(studentSubjectsToExpose));
        }
Пример #3
0
        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));
        }