public static void RelateStudentsAssignments()
        {
            using (MyContext db = new MyContext())
            {
                GetAllStudents();
                AssignmentManager.GetAllAssignments();
                Console.WriteLine("\nPLease relate the Students and the Assignments they have\n");
                Console.WriteLine("Select a student ID from the student's list: ");
                int id_s = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Select a Assignment ID from the Assignments' list: ");
                int id_a = Convert.ToInt32(Console.ReadLine());


                // Assignment A = new Assignment();
                Assignment A1 = db.Assignments.Find(id_a);
                // Student S = new Student();
                Student           S1 = db.Students.Find(id_s);
                StudentAssignment SA = new StudentAssignment();
                SA.Student      = S1;
                SA.Assignment   = A1;
                SA.StudentID    = id_s;
                SA.AssignmentID = id_a;
                db.StudentAssignments.Add(SA);
                db.SaveChanges();
                Console.WriteLine("Input has been successfully submitted\n");
            }
        }
Пример #2
0
 public static void RelateAssignmentsToCourses()
 {
     using (MyContext db = new MyContext())
     {
         Console.WriteLine("Please add Assignment to the course using the ID's from the lists");
         GetAllCourses();
         AssignmentManager.GetAllAssignments();
         Console.Write("Select the Course id from the list you want to add an assignment: ");
         int id_c = Convert.ToInt32(Console.ReadLine());
         Console.Write("Select the Assignment id from the list you want to add to the course: ");
         int        id_a = Convert.ToInt32(Console.ReadLine());
         Course     C1   = db.Courses.Find(id_c);
         Assignment A1   = db.Assignments.Find(id_a);
         C1.Assignments.Add(A1);
         db.SaveChanges();
         Console.WriteLine("\nAssignment successfully submitted to the course");
     }
 }
Пример #3
0
 public static void RelateAssignmentsToTrainers()
 {
     using (MyContext db = new MyContext())
     {
         Console.WriteLine("Please add Assignment to the Trainer using the ID's from the lists");
         GetAllTrainers();
         AssignmentManager.GetAllAssignments();
         Console.Write("Select the Trainer id from the list you want to add an assignment: ");
         int id_t = Convert.ToInt32(Console.ReadLine());
         Console.Write("Select the Assignment id from the list you want to add to the course: ");
         int        id_a = Convert.ToInt32(Console.ReadLine());
         Trainer    T    = new Trainer();
         Trainer    T1   = db.Trainers.Find(id_t);
         Assignment A    = new Assignment();
         Assignment A1   = db.Assignments.Find(id_a);
         T1.Assignments.Add(A1);
         db.SaveChanges();
         Console.WriteLine("\nAssignment successfully submitted to the trainer");
     }
 }