Exemplo n.º 1
0
        public void GetAllTrainersPerCourses(School school)
        {
            SqlCommand    cmdTrainerPerCourse     = new SqlCommand("SELECT * FROM TrainerPerCourse", sqlConnection);
            SqlDataReader readerTrainerPerCourses = cmdTrainerPerCourse.ExecuteReader();

            while (readerTrainerPerCourses.Read())
            {
                Trainer trainer             = school.Trainers.SingleOrDefault(t => t.ID == readerTrainerPerCourses.GetInt32(0));
                Course  course              = school.Courses.SingleOrDefault(c => c.ID == readerTrainerPerCourses.GetInt32(1));
                var     newTrainerPerCourse = new TrainerPerCourse(trainer, course);
                trainer.Courses.Add(newTrainerPerCourse);
                course.Trainers.Add((newTrainerPerCourse));
                school.TrainersPerCourses.Add(newTrainerPerCourse);
            }
            readerTrainerPerCourses.Close();
        }
Exemplo n.º 2
0
 public void AddTrainerPerCOurse(TrainerPerCourse trainerPerCourse)
 {
     TrainersPerCourses.Add(trainerPerCourse);
 }