public static void EnrollStudentToCourse(Person p)
        {
            Console.WriteLine("Select from the Courses");
            ShowCourses();
            int courseId = GetNumberInput("Enter the course number:\t");

            if (controller.CourseExists(courseId))
            {
                StudentGrade sg = new StudentGrade();

                sg.StudentID = p.PersonID;
                sg.CourseID  = courseId;
                controller.EnrollStudentToCourse(sg);

                Console.Write("\t\t\t\tDo you want to enroll more courses to the the student {0} {1}? (y/n)\t", p.FirstName, p.LastName);
                string ans = Console.ReadLine().ToUpper();
                if (ans.Equals("Y"))
                {
                    EnrollStudentToCourse(p);
                }
            }
            else
            {
                Console.WriteLine("You have entered an invalid input");
                EnrollStudentToCourse(p);
            }
        }
Exemple #2
0
 public void EnrollStudentToCourse(StudentGrade sg)
 {
     schoolDB = new SchoolEntities();
     schoolDB.StudentGrades.Add(sg);
     schoolDB.SaveChanges();
 }