Esempio n. 1
0
        public Course RemoveLecturer(int courseId, int lecturerId)
        {
            var course   = _courseRepository.GetById(courseId);
            var lecturer = _userRepository.GetById(lecturerId);

            if (course == null || lecturer == null || !UserServices.IsUserLecturer(lecturer))
            {
                return(null);
            }
            course.LecturersInCharge.Remove((Lecturer)lecturer);
            return(_courseRepository.Update(course));
        }
Esempio n. 2
0
        public List <Course> GetCoursesByLecturerId(int id)
        {
            var lecturer = _userRepository.GetById(id);

            if (lecturer == null || !UserServices.IsUserLecturer(lecturer))
            {
                return(null);
            }

            var courses = _courseRepository.GetByLecturerInChargerId(id);

            if (courses == null)
            {
                return(null);
            }

            var coursesList = courses.ToList();

            coursesList.Sort((c1, c2) => c1.Name.CompareTo(c2.Name));
            return(coursesList);
        }