Exemplo n.º 1
0
        public List <CoursesPerStudent> MultyCoursesPerSrudent()
        {
            List <Student>       students = GetAll();
            List <Course>        courses  = new CourseService().GetAll();
            List <StudentCourse> watches  = new StudentCourseService().GetAll();

            var querySql = from s in students
                           join w in watches
                           on s.StudentId equals w.StudentId
                           join w1 in watches
                           on w.StudentId equals w1.StudentId
                           join c in courses
                           on w.CourseId equals c.CourseId
                           where w.CourseId != w1.CourseId
                           select new
            {
                Student = s,
                Course  = c
            };

            List <CoursesPerStudent> MultyCoursesPerSrudent = new List <CoursesPerStudent>();
            var groupedByStudents = querySql.GroupBy(s => s.Student);

            foreach (var group in groupedByStudents)
            {
                CoursesPerStudent coursesPerStudent = new CoursesPerStudent();
                coursesPerStudent.Student = group.Key;
                foreach (var item in group.Distinct())
                {
                    //count++;
                    coursesPerStudent.Courses.Add(item.Course);
                }

                MultyCoursesPerSrudent.Add(coursesPerStudent);
            }
            return(MultyCoursesPerSrudent);
        }
Exemplo n.º 2
0
        public Data()
        {
            //creating students
            Student s1 = new Student("Panagiotis", "Grigoriou", new DateTime(1987, 3, 4), 3000);
            Student s2 = new Student("Konstantinos", "Pantelidis", new DateTime(1991, 6, 2), 4000);
            Student s3 = new Student("Spiros", "Aggelatos", new DateTime(1996, 4, 7), 3500);
            Student s4 = new Student("Dimitris", "Pantelopoulos", new DateTime(2000, 5, 2), 6200);
            Student s5 = new Student("Antonis", "Mixelakakis", new DateTime(1989, 10, 3), 5800);

            Students.Add(s1);
            Students.Add(s2);
            Students.Add(s3);
            Students.Add(s4);
            Students.Add(s5);

            //creating courses
            Course c1 = new Course("Javascript", "Web Development", "Practical Subject", new DateTime(2020, 1, 10), new DateTime(2020, 3, 11));
            Course c2 = new Course("C++", "Object-Oriented Programming", "Practical Subject", new DateTime(2020, 1, 18), new DateTime(2020, 4, 2));
            Course c3 = new Course("Pascal", "Procedural Programming", "Theoretical Subject", new DateTime(2020, 2, 15), new DateTime(2020, 5, 20));
            Course c4 = new Course("Visual Basic", "Windows Application Development", "Practical Subject", new DateTime(2020, 3, 20), new DateTime(2020, 6, 1));

            Courses.Add(c1);
            Courses.Add(c2);
            Courses.Add(c3);
            Courses.Add(c4);

            //creating trainers
            Trainer t1 = new Trainer("Giannis", "Aggelopoulos", "Object-Oriented Programming");
            Trainer t2 = new Trainer("Manolis", "Daskalakis", "Procedural Programming");
            Trainer t3 = new Trainer("Giorgos", "Mpatzoglou", "Procedural Programming");
            Trainer t4 = new Trainer("Thanassis", "Giorgakopoulos", "Object-Oriented Programming");

            Trainers.Add(t1);
            Trainers.Add(t2);
            Trainers.Add(t3);
            Trainers.Add(t4);

            //creating assignments
            Assignment a1 = new Assignment("Project Bank", "Banking application for android phones", new DateTime(2020, 4, 24), 40, 200);
            Assignment a2 = new Assignment("Project E-shop", "Shopping website", new DateTime(2020, 6, 11), 20, 100);
            Assignment a3 = new Assignment("Project Library", "Book rental service", new DateTime(2020, 4, 15), 35, 200);
            Assignment a4 = new Assignment("Project Cinema", "Movie distribution to cinemas", new DateTime(2020, 1, 2), 73, 100);
            Assignment a5 = new Assignment("Project Stocks", "Stock change notifications", new DateTime(2020, 3, 27), 110, 200);
            Assignment a6 = new Assignment("Project Architecture", "Blueprint making software", new DateTime(2020, 3, 24), 40, 150);

            Assignments.Add(a1);
            Assignments.Add(a2);
            Assignments.Add(a3);
            Assignments.Add(a4);
            Assignments.Add(a5);
            Assignments.Add(a6);

            //putting students in mini-lists (students per Course)
            List <Student> C1Stu = new List <Student>();
            List <Student> C2Stu = new List <Student>();
            List <Student> C3Stu = new List <Student>();

            C1Stu.Add(s2);
            C1Stu.Add(s3);

            C2Stu.Add(s1);
            C2Stu.Add(s2);
            C2Stu.Add(s3);

            C3Stu.Add(s1);

            //putting mini-lists in big lists (students per Course)
            StudentPerCourse stuPerCour1 = new StudentPerCourse(c1, C1Stu);
            StudentPerCourse stuPerCour2 = new StudentPerCourse(c2, C2Stu);
            StudentPerCourse stuPerCour3 = new StudentPerCourse(c3, C3Stu);

            StudentsPerCourse.Add(stuPerCour1);
            StudentsPerCourse.Add(stuPerCour2);
            StudentsPerCourse.Add(stuPerCour3);

            //putting trainers in mini-lists (trainers per Course)
            List <Trainer> C1Train = new List <Trainer>();
            List <Trainer> C2Train = new List <Trainer>();
            List <Trainer> C3Train = new List <Trainer>();

            C1Train.Add(t1);
            C1Train.Add(t2);

            C2Train.Add(t1);
            C2Train.Add(t3);

            C3Train.Add(t4);
            C3Train.Add(t1);

            //putting mini-lists in big lists (trainers per Course)
            TrainerPerCourse trainPerCour1 = new TrainerPerCourse(c1, C1Train);
            TrainerPerCourse trainPerCour2 = new TrainerPerCourse(c2, C2Train);
            TrainerPerCourse trainPerCour3 = new TrainerPerCourse(c3, C3Train);

            TrainersPerCourse.Add(trainPerCour1);
            TrainersPerCourse.Add(trainPerCour2);
            TrainersPerCourse.Add(trainPerCour3);

            //putting assignments in mini-lists (assignments per Course)
            List <Assignment> C1Assign = new List <Assignment>();
            List <Assignment> C2Assign = new List <Assignment>();
            List <Assignment> C3Assign = new List <Assignment>();

            C1Assign.Add(a1);
            C1Assign.Add(a2);

            C2Assign.Add(a3);

            C3Assign.Add(a5);
            C3Assign.Add(a4);

            //putting mini-lists in big lists (assignments per Course)
            AssignmentPerCourse assignPerCour1 = new AssignmentPerCourse(c1, C1Assign);
            AssignmentPerCourse assignPerCour2 = new AssignmentPerCourse(c2, C2Assign);
            AssignmentPerCourse assignPerCour3 = new AssignmentPerCourse(c3, C2Assign);

            AssignmentsPerCourse.Add(assignPerCour1);
            AssignmentsPerCourse.Add(assignPerCour2);
            AssignmentsPerCourse.Add(assignPerCour3);

            //putting assignments in mini-lists (assignments per Student)
            List <Assignment> S1Assign = new List <Assignment>();
            List <Assignment> S2Assign = new List <Assignment>();
            List <Assignment> S3Assign = new List <Assignment>();

            S1Assign.Add(a1);
            S1Assign.Add(a2);

            S2Assign.Add(a3);
            S2Assign.Add(a4);
            S2Assign.Add(a5);

            S3Assign.Add(a6);

            //putting mini-lists in big lists (assignments per Student)
            AssignmentPerStudent assignPerStu1 = new AssignmentPerStudent(s1, S1Assign);
            AssignmentPerStudent assignPerStu2 = new AssignmentPerStudent(s2, S2Assign);
            AssignmentPerStudent assignPerStu3 = new AssignmentPerStudent(s3, S3Assign);

            AssignmentsPerStudent.Add(assignPerStu1);
            AssignmentsPerStudent.Add(assignPerStu2);
            AssignmentsPerStudent.Add(assignPerStu3);

            //putting courses in mini-lists (courses per Student)
            List <Course> S1Cour = new List <Course>();
            List <Course> S2Cour = new List <Course>();
            List <Course> S3Cour = new List <Course>();

            S1Cour.Add(c2);
            S1Cour.Add(c3);


            S2Cour.Add(c1);
            S2Cour.Add(c2);

            S3Cour.Add(c1);
            S3Cour.Add(c2);

            //putting mini-lists in big lists (courses per Student)
            CoursePerStudent courPerStu1 = new CoursePerStudent(s1, S1Cour);
            CoursePerStudent courPerStu2 = new CoursePerStudent(s2, S2Cour);
            CoursePerStudent courPerStu3 = new CoursePerStudent(s3, S3Cour);


            CoursesPerStudent.Add(courPerStu1);
            CoursesPerStudent.Add(courPerStu2);
            CoursesPerStudent.Add(courPerStu3);

            //-------------------------------------------------------

            //AssignmentCourseStudent ACS1 = new AssignmentCourseStudent(s1, c2, a3);
            //AssignmentCourseStudent ACS2 = new AssignmentCourseStudent(s1, c3, a6);
            //AssignmentCourseStudent ACS3 = new AssignmentCourseStudent(s2, c1, a1);
            //AssignmentCourseStudent ACS4 = new AssignmentCourseStudent(s2, c2, a4);
            //AssignmentCourseStudent ACS5 = new AssignmentCourseStudent(s3, c1, a2);
            //AssignmentCourseStudent ACS6 = new AssignmentCourseStudent(s3, c2, a5);

            //ACSList.Add(ACS1);
            //ACSList.Add(ACS2);
            //ACSList.Add(ACS3);
            //ACSList.Add(ACS4);
            //ACSList.Add(ACS5);
            //ACSList.Add(ACS6);
        }