Exemplo n.º 1
0
        public Student getStudentdata(int id)
        {
            var user = _userRepository.GetById(id);

            if (user != null && UserServices.IsUserStudent(user))
            {
                return((Student)user);
            }
            return(null);
        }
Exemplo n.º 2
0
        public Course RemoveStudent(int courseId, int studentId)
        {
            var course  = _courseRepository.GetById(courseId);
            var student = _userRepository.GetById(studentId);

            if (course == null || student == null || !UserServices.IsUserStudent(student))
            {
                return(null);
            }
            course.StudentsEnrolled.Remove((Student)student);
            return(_courseRepository.Update(course));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }