Beispiel #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


        public void DeregisterStudent(string studentId)
        {
            var student = _srepo.Get(studentId) ?? new Student();

            //is this a valid student?
            if (student.Id == null)
            {
                throw new UpdateException(string.Format("student with id {0}", studentId));
            }
            //deregister the student from all courses they were registered to
            //here
            var enrollment = _cerepo.GetAll();

            foreach (var item in enrollment)
            {
                if (item.Id == studentId)
                {
                    _cerepo.Remove(item);
                }
            }
            var result = _srepo.Remove(student);
        }
Beispiel #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public List <Student> GetRegisteredStudentsForCourse(string courseId)
        {
            var students = new List <Student>();
            var course   = _crepo.Get(courseId) ?? new Course();

            if (course.Id == null)
            {
                throw new NotFoundException("msg");
            }
            var enrolled = _cerepo.GetAll().Where(x => x.CourseId == course.Id && x.IsAdmin == false).ToList() ?? new List <CourseEnrollment>();

            if (enrolled.Count() == 0)
            {
                return(new List <Student>());
            }
            enrolled.ForEach(e => students.Add(_srepo.Get(e.Id)));
            return(students);
        }
Beispiel #3
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public List <Course> ListTeacherCourses(string teacherId)
        {
            var courses = new List <Course>();
            var teacher = _trepo.Get(teacherId) ?? new Teacher();

            if (teacher.Id == null)
            {
                throw new NotFoundException(string.Format("cannot list courses. teacher with id {0} not found.", teacherId));
            }

            var enrollment = _cerepo.GetAll().Where(c => c.Id == teacherId && c.IsAdmin == true) as List <CourseEnrollment>;

            if (enrollment.Count == 0)
            {
                return(courses);
            }

            enrollment.ForEach(x => courses.Add(_crepo.Get(x.CourseId)));
            return(courses);
        }