Ejemplo n.º 1
0
        public static void Show()
        {
            privateschoolEntities dbContex = new privateschoolEntities();

            int counter = 0;

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("*******************************************");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine($"Students enlisted in more than one Courses: ");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("*******************************************");

            foreach (var student in dbContex.students)
            {
                if (student.courses.Count > 1)
                {
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine($"{student.firstname}  {student.lastname}");
                    counter++;
                }
                Console.ForegroundColor = ConsoleColor.White;
            }
            if (counter == 0)
            {
                Console.WriteLine("There aren't any Students Enlisted in more than one Courses.");
                Console.WriteLine();
            }
        }
Ejemplo n.º 2
0
        public void InputCourseID()
        {
            privateschoolEntities dbContex = new privateschoolEntities();
            bool valid = true;

            do
            {
                try
                {
                    Console.WriteLine("Type the ID of the COURSE of the Assignment:  ");
                    Assignment.courseid = Convert.ToInt32(Console.ReadLine());

                    var courseExists = dbContex.courses.Any(c => c.id == Assignment.courseid);

                    if (!courseExists)
                    {
                        Console.WriteLine("The course ID you typed doesn't Exist !!!");
                    }
                    else
                    {
                        Console.WriteLine($"You successfully added the assignment to Course with ID:  {Assignment.courseid}  !!! ");
                        valid = false;
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Type a Correct Course ID !!!");
                }
            } while (valid);
        }
Ejemplo n.º 3
0
        public static void Show()
        {
            privateschoolEntities dbContex = new privateschoolEntities();

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("++++++++++ ASSIGNMENTS PER COURSE +++++++++ ");
            Console.ForegroundColor = ConsoleColor.Yellow;

            foreach (var course in dbContex.courses)
            {
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine($"Course  {course.title}  Has {course.assignments.Count}  Assignments:");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("---------------------+--------------------------------+----------------------+------------+--------------+");
                Console.WriteLine("{0,-21}| {1,-30 } | {2,-20} | {3,-9}  | {4,-12} ", "Title", "Description", "Submission Date", "Oral Mark", "Total Mark");
                Console.WriteLine("---------------------+--------------------------------+----------------------+------------+--------------+");
                Console.ForegroundColor = ConsoleColor.White;
                foreach (var item in course.assignments)
                {
                    Console.WriteLine($"{item.title,-20} | {item.description,-30} | {item.subdatetime.ToString("dd/MM/yyyy"),-20} | {item.oralmark,-10} | {item.totalmark,-12}");
                }
                Console.WriteLine("---------------------+--------------------------------+----------------------+------------+--------------+");
            }
        }
Ejemplo n.º 4
0
        public void InputID()
        {
            privateschoolEntities dbContex = new privateschoolEntities();
            bool valid = true;

            do
            {
                try
                {
                    Console.WriteLine(" Type the Trainer ID:  ");
                    Trainer.id = Convert.ToInt32(Console.ReadLine());

                    var trainerExists = dbContex.trainers.Any(t => t.id == Trainer.id);

                    if (trainerExists)
                    {
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.WriteLine("The Trainer ID already exists !!! ");
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    else
                    {
                        valid = false;
                    }
                }
                catch (Exception)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Type a correct ID !!!!");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            } while (valid);
        }
Ejemplo n.º 5
0
        public void MultipleTrainerInput()
        {
            bool valid = true;

            do
            {
                TrainerDataCapture trainerCapture = new TrainerDataCapture();
                trainers           trainer        = trainerCapture.Capture();

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


                if (value == "NO" || value == "No" || value == "no")
                {
                    valid = false;
                }
            } while (valid);
        }
        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);
        }
Ejemplo n.º 7
0
        public static void Show()
        {
            privateschoolEntities dbContex = new privateschoolEntities();

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("++++++++++ STUDENTS PER COURSE +++++++++ ");
            Console.ForegroundColor = ConsoleColor.Yellow;

            foreach (var course in dbContex.courses)
            {
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine($"Course  {course.title}  Has {course.students.Count}  students:");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("----------------+----------------------+----------------------+-----------------+--------------------+");
                Console.WriteLine("{0,-16}| {1,-20 } | {2,-20} | {3,-15} | {4,-15}  ", "First Name", "Last Name", "Date of Birth", "Tuition Fees", "Student ID");
                Console.WriteLine("----------------+----------------------+----------------------+-----------------+--------------------+");
                Console.ForegroundColor = ConsoleColor.White;
                foreach (var item in course.students)
                {
                    Console.WriteLine($"{item.firstname,-15 } | {item.lastname,-20} | {item.dateofbirth.ToString("dd/MM/yyyy"),-20} | {item.tuitionfees,-15} | {item.id,-15}  ");
                }
                Console.WriteLine("----------------+----------------------+----------------------+-----------------+--------------------+");
            }
        }
        public static void Show()
        {
            privateschoolEntities dbContex = new privateschoolEntities();

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("++++++++++ TRAINERS PER COURSE +++++++++ ");
            Console.ForegroundColor = ConsoleColor.Yellow;

            foreach (var course in dbContex.courses)
            {
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine($"Course  {course.title}  Has {course.trainers.Count}  Trainers:");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("----------------+----------------------+----------------------+-----------------+--------------------+");
                Console.WriteLine("{0,-16}| {1,-20 } | {2,-20} | {3,-15} | {4,-20}  ", "First Name", "Last Name", "Teaching Subject", "Trainer ID", "Teaching Course");
                Console.WriteLine("----------------+----------------------+----------------------+-----------------+--------------------+");
                Console.ForegroundColor = ConsoleColor.White;
                foreach (var item in course.trainers)
                {
                    Console.WriteLine($"{item.firstname,-15 } | {item.lastname,-20} | {item.subject,-15} | {item.id,-15} | {item.courses.title,-20} ");
                }
                Console.WriteLine("----------------+----------------------+----------------------+-----------------+--------------------+");
            }
        }
Ejemplo n.º 9
0
        public void InputID()
        {
            privateschoolEntities dbContex = new privateschoolEntities();
            bool valid = true;

            do
            {
                try
                {
                    Console.WriteLine(" Type the ID of the Assignment:  ");
                    Assignment.id = Convert.ToInt32(Console.ReadLine());

                    var assignExists = dbContex.assignments.Any(a => a.id == Assignment.id);

                    if (assignExists)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("The Assignment ID already exists !!! ");
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    else
                    {
                        valid = false;
                    }
                }
                catch (Exception)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Type a correct ID !!!!");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            } while (valid);
        }
Ejemplo n.º 10
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 static void Show()
        {
            privateschoolEntities dbContex = new privateschoolEntities();

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("List of All Courses                                              ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("----------------------+-----------------+------------+------------+------------+-----------+");
            Console.WriteLine("{0,-23}| {1,-15 } | {2,-10} | {3,9}  | {4,-9} | {5,-10}", "Title", "Type", "Stream", "Start Date", "End Date", "Course ID");
            Console.WriteLine("----------------------+-----------------+------------+------------+------------+-----------+");
            Console.ForegroundColor = ConsoleColor.White;
            foreach (var item in dbContex.courses)
            {
                Console.WriteLine($" {item.title,-20 } | {item.type,-15} | {item.stream,-10} | {item.start_date.ToString("dd/MM/yyyy"),-10} | {item.end_date.ToString("dd/MM/yyyy"),-9} | {item.id,-4} ");
            }
            Console.WriteLine("----------------------+-----------------+------------+------------+------------+-----------+");
        }
Ejemplo n.º 12
0
        public static void Show()
        {
            privateschoolEntities dbContex = new privateschoolEntities();

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("List of All Assignments                                              ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("---------------------+--------------------------------+----------------------+------------+--------------+-----------------+");
            Console.WriteLine("{0,-21}| {1,-30 } | {2,-20} | {3,-9}  | {4,-12} | {5,-10} ", "Title", "Description", "Submission Date", "Oral Mark", "Total Mark", "Course Name");
            Console.WriteLine("---------------------+--------------------------------+----------------------+------------+--------------+-----------------+");
            Console.ForegroundColor = ConsoleColor.White;
            foreach (var item in dbContex.assignments)
            {
                Console.WriteLine($"{item.title,-20} | {item.description,-30} | {item.subdatetime.ToString("dd/MM/yyyy"),-20} | {item.oralmark,-10} | {item.totalmark,-12} | {item.courses.title,-10}");
            }
            Console.WriteLine("---------------------+--------------------------------+----------------------+------------+--------------+-----------------+");
        }
Ejemplo n.º 13
0
        public static void Show()
        {
            privateschoolEntities dbContex = new privateschoolEntities();

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("List of All Trainers                                              ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("----------------+----------------------+--------------------------------+----------------+");
            Console.WriteLine("{0,-16}| {1,-20 } | {2,-30} | {3,-15}", "First Name", "Last Name", "Subject", "Teaching Course");
            Console.WriteLine("----------------+----------------------+--------------------------------+----------------+");
            Console.ForegroundColor = ConsoleColor.White;

            foreach (var item in dbContex.trainers)
            {
                Console.WriteLine($"{item.firstname,-15 } | {item.lastname,-20} | {item.subject,-30} | {item.courses.title,-15}");
            }
            Console.WriteLine("----------------+----------------------+--------------------------------+----------------+");
        }
Ejemplo n.º 14
0
        public static void Show()
        {
            privateschoolEntities dbContex = new privateschoolEntities();

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("List of All Students");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("----------+----------------+----------------------+----------------------+-----------------+-");
            Console.WriteLine("{0,-10} | {1,-16} | {2,-20 } | {3,-20} | {4,-15} ", "student ID", "First Name", "Last Name", "Date of Birth", "Tuition Fees");
            Console.WriteLine("----------+----------------+----------------------+----------------------+-----------------+-");
            Console.ForegroundColor = ConsoleColor.White;
            var studs = dbContex.students.OrderBy(s => s.firstname).ThenBy(l => l.lastname);

            foreach (var item in studs)
            {
                Console.WriteLine($"{item.id, -10} | {item.firstname,-15 } | {item.lastname,-20} | {item.dateofbirth.ToString("dd/MM/yyyy"),-20} | {item.tuitionfees,-15} ");
            }
            Console.WriteLine("---------+----------------+----------------------+----------------------+-----------------+-");
        }
        public static void Show()
        {
            privateschoolEntities dbContex = new privateschoolEntities();

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("++++++++++ ASSIGNMENTS PER COURSE PER STUDENT +++++++++ ");
            Console.ForegroundColor = ConsoleColor.Yellow;

            foreach (var student in dbContex.students)
            {
                var courseAsssingments = student.assignments.Join(student.courses,
                                                                  a => a.courseid,
                                                                  c => c.id,
                                                                  (assignment, course) => new
                {
                    assignmentname        = assignment.title,
                    assignmentdescription = assignment.description,
                    assignmentDate        = assignment.subdatetime,
                    courseid    = course.id,
                    courseTitle = course.title
                });
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine($"Student  {student.firstname}  {student.lastname}  Has to submit the following assignments per course:");
                Console.ForegroundColor = ConsoleColor.Yellow;

                Console.WriteLine("---------------------+--------------------------------+----------------------+------------+-------------------+");
                Console.WriteLine("{0,-21}| {1,-30 } | {2,-20} | {3,-9}  | {4,-12} ", "Assignment Title", "Assignment Description", "Submission Date", "Course ID", "Course Title");
                Console.WriteLine("---------------------+--------------------------------+----------------------+------------+-------------------+");
                Console.ForegroundColor = ConsoleColor.White;

                foreach (var item in courseAsssingments)
                {
                    Console.WriteLine($"{item.assignmentname,-20} | {item.assignmentdescription,-30} | {item.assignmentDate.ToString("dd/MM/yyyy"),-20} | {item.courseid,-10} | {item.courseTitle,-20}");
                }
                Console.WriteLine("---------------------+--------------------------------+----------------------+------------+-------------------+");
            }
        }
        public void MultipleAssignmentInput()
        {
            bool valid = true;

            do
            {
                AssignmentDataCapture assignmentCapture = new AssignmentDataCapture();
                assignments           assignment        = assignmentCapture.Capture();

                using (privateschoolEntities dbContex = new privateschoolEntities())
                {
                    dbContex.assignments.Add(assignment);
                    foreach (var student in dbContex.students)
                    {
                        if (student.courses.Contains(assignment.courses))
                        {
                            student.assignments.Add(assignment);
                        }
                    }

                    dbContex.SaveChanges();
                }
                Console.WriteLine();
                Music.EndBeep();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("ASSIGNMENT HAS BEEN CREATED");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Do you want to create another assignment?  Press 'NO' or 'no' to exit.");
                Console.WriteLine("Type anything else to continue creating another Assignment");
                Console.ForegroundColor = ConsoleColor.White;
                string value = Console.ReadLine();

                if (value == "NO" || value == "No" || value == "no")
                {
                    valid = false;
                }
            } while (valid);
        }
        public void InputID()
        {
            privateschoolEntities dbContex = new privateschoolEntities();
            bool valid = true;

            do
            {
                try
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("+++++++++< CREATE A NEW COURSE >++++++++++");
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine(" Type the Course ID:  ");
                    Course.id = Convert.ToInt32(Console.ReadLine());

                    var courseExists = dbContex.courses.Any(c => c.id == Course.id);

                    if (courseExists)
                    {
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.WriteLine("The Course ID already exists !!! ");
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    else
                    {
                        valid = false;
                    }
                }
                catch (Exception)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Type a correct ID !!!!");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            } while (valid);
        }
Ejemplo n.º 18
0
        public void InputCourseID()
        {
            privateschoolEntities dbContex = new privateschoolEntities();
            bool valid = true;

            do
            {
                try
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(" Type the ID of the COURSE of the Trainer:  ");
                    Trainer.courseid        = Convert.ToInt32(Console.ReadLine());
                    Console.ForegroundColor = ConsoleColor.White;
                    var trainerExists = dbContex.courses.Any(c => c.id == Trainer.courseid);

                    if (!trainerExists)
                    {
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.WriteLine("The course ID you typed doesn't Exist !!!");
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine($"You successfully added the assignment to Course with ID:  {Trainer.courseid}  !!! ");
                        Console.ForegroundColor = ConsoleColor.White;
                        valid = false;
                    }
                }
                catch (Exception)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Type a Correct Course ID !!!");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            } while (valid);
        }
        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);
        }