Exemple #1
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);
        }
Exemple #2
0
        public List <Course> GetCoursesByUserId(int id)
        {
            var student = _userRepository.GetById(id);

            if (student == null || !UserServices.IsUserStudent(student))
            {
                return(null);
            }

            var courses = _courseRepository.GetByStudentEnroledId(id);

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

            var coursesList = courses.ToList();

            coursesList.Sort((c1, c2) => c1.Name.CompareTo(c2.Name));
            return(coursesList);
        }
Exemple #3
0
        public IList <Score> GetScorebyStudentAndCourse(int studentId, int courseId)
        {
            var student = _userRepository.GetById(studentId);

            if (student == null || !UserServices.IsUserStudent(student))
            {
                return(new List <Score>());
            }



            var course        = _courseRepository.GetById(courseId);
            var componentList = course.Components;

            if (componentList == null)
            {
                return(new List <Score>());
            }

            var scoreList = new List <Score>();

            foreach (var component in componentList)
            {
                var score = _scoreRepository.GetByStudentIdAndComponentId((Student)student, component);
                if (score == null)
                {
                    var defaultScore = new Score()
                    {
                        Student   = (Student)student,
                        Component = component,
                        Value     = 0,
                    };
                    score = _scoreRepository.CreateOrUpdate(defaultScore);
                }
                scoreList.Add(score);
            }


            return(scoreList);
        }