public void MultipleCourseInput()

        {
            bool valid = true;

            do
            {
                CourseDataCapture courseCapture = new CourseDataCapture();
                courses           course        = courseCapture.Capture();

                using (privateschoolEntities dbContex = new privateschoolEntities())
                {
                    dbContex.courses.Add(course);
                    dbContex.SaveChanges();
                }
                Music.EndBeep();
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("COURSE HAS BEEN CREATED");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Do you want to create another course?  Press 'NO' or 'no' to exit.");
                Console.WriteLine("Type anything else to continue creating another Course");
                Console.ForegroundColor = ConsoleColor.White;
                string value = Console.ReadLine();

                if (value == "NO" || value == "No" || value == "no")
                {
                    valid = false;
                }
            } while (valid);
        }
Exemple #2
0
        public static void Enroll()
        {
            //List<assignments> assignments = new List<assignments>();
            StudentDataCapture studentCapture = new StudentDataCapture();
            students           student        = studentCapture.Capture();

            privateschoolEntities dbContex = new privateschoolEntities();

            try
            {
                Console.WriteLine("which course do you want the student to attend?(type course ID!): ");
                int studentcourse = Convert.ToInt32(Console.ReadLine());

                var  courseExists = dbContex.courses.Any(c => c.id == studentcourse);
                bool validd       = true;
                do
                {
                    if (!courseExists)
                    {
                        Console.WriteLine("The course ID you typed doesn't Exist !!!");
                        validd = false;
                    }
                    else
                    {
                        courses course = dbContex.courses.First(c => c.id == studentcourse);
                        student.courses.Add(course);

                        foreach (var assign in dbContex.assignments)
                        {
                            if (course.assignments.Contains(assign))
                            {
                                student.assignments.Add(assign);
                            }
                        }

                        Console.WriteLine($"You successfully added the Student to Course with ID:  {studentcourse}  !!! ");
                        validd = false;
                    }
                } while (validd);
            }
            catch (Exception)
            {
                Console.WriteLine("Type a Correct Course ID !!!");
            }

            dbContex.students.Add(student);
            dbContex.SaveChanges();
        }
 public InputCourse()
 {
     Course = new courses();
 }
        public static void Now()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            AppMessages.EnrollHiMessage();
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine();
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("++++++++++ INPUT STUDENT TO ANOTHER COURSE +++++++++++");
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(" Do you want to input a Student into another Course? ");
            Console.WriteLine(" Press 'NO' or 'no' to exit or ENTER to Continue!");
            Console.ForegroundColor = ConsoleColor.White;
            privateschoolEntities dbContex = new privateschoolEntities();

            string value = Console.ReadLine();

            if (value == "NO" || value == "No" || value == "no")
            {
                return;
            }
            Console.WriteLine("COURSES: ");
            foreach (var item in dbContex.courses)
            {
                Console.WriteLine($" {item.id,-5}  |  {item.title} ");
            }
            Console.WriteLine();
            Console.WriteLine("STUDENTS:  ");
            foreach (var student1 in dbContex.students)
            {
                Console.WriteLine($" { student1.id,-5} | {student1.firstname}  {student1.lastname}");
            }
            Console.WriteLine();

            bool validd = true;

            do
            {
                try
                {
                    Console.WriteLine("which Student do you want to select ??? (type student ID!): ");
                    int studentid = Convert.ToInt32(Console.ReadLine());
                    //
                    var studentExists = dbContex.students.Any(s => s.id == studentid);
                    if (!studentExists)
                    {
                        throw new Exception("The Student ID you typed doesn't Exist !!!");
                    }
                    //
                    students student = dbContex.students.First(s => s.id == studentid);
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine($"You Selected the Student {student.firstname.ToString().ToUpper()} {student.lastname.ToString().ToUpper()} with ID: {student.id}");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    //
                    Console.WriteLine("Which Course do you want him/her to Enroll to???? (TYPE A COURSE ID!!)");
                    int courseid = Convert.ToInt32(Console.ReadLine());
                    Console.ForegroundColor = ConsoleColor.White;
                    //
                    courses course = dbContex.courses.First(c => c.id == courseid);
                    student.courses.Add(course);

                    foreach (var assign in course.assignments)
                    {
                        student.assignments.Add(assign);
                    }
                    course.students.Add(student);
                    dbContex.SaveChanges();

                    Console.WriteLine($"You successfully added {student.firstname} {student.lastname} to another Course !!! ");
                    validd = false;
                }
                catch (Exception)
                {
                    Console.WriteLine("Wrong ID please try again!!!");
                }
            } while (validd);
        }
Exemple #5
0
 public void Show(courses course)
 {
     Console.WriteLine($"{course.title,-5 } | {course.type,-10} | {course.stream,-10} | {course.start_date.ToString("dd/MM/yyyy"),-10} | {course.end_date.ToString("dd/MM/yyyy"),-9} |");
 }