Ejemplo n.º 1
0
        public static menuIDs assignmentMenu()
        {
            //menuID = "140";
            Console.WriteLine("Assignment menu\n");
            Console.WriteLine("Please choose what you want to do:\n" +
                              "1. back\n" +
                              "2. add a new assignment\n" +
                              "3. add an assignment to a course\n" +
                              "4. see all assignments\n" +
                              "5. see the students who need to submit assignments in a date\n" +
                              "6. see all the assignments per course per student\n" +
                              "7. see all the connections of all assignments\n" +
                              "EXIT to exit program\n");

            int selection = Helper.menuSelectionChecker(7, true);

            menuIDs IDselect = menuIDs.assignmentMenu;

            switch (selection)
            {
            case 1:
                IDselect = menuIDs.centralMenu;
                break;

            case 2:
                ProjectHelper.addNew(availableTypes.Assignment);
                break;

            case 3:
                ProjectHelper.addToCourse(availableTypes.Assignment);
                break;

            case 4:
                IndividualPartBModel db = new IndividualPartBModel();
                HelperDB.showDbByType(db.Assignments.ToList());
                break;

            case 5:
                ProjectHelper.showAssignmentDates();
                break;

            case 6:
                HelperDB.showAssignmentPerCoursePerStudentt();
                break;

            case 7:
                ProjectHelper.showAllConnections(availableTypes.Assignment);
                break;

            default:
                IDselect = menuIDs.exit;
                break;
            }
            if (selection == 4 || selection == 6 || selection == 7)
            {
                Console.WriteLine("Please press any key to continue.");
                Console.ReadKey();
            }
            return(IDselect);
        }
        public static Assignments chooseAssignment()
        {
            IndividualPartBModel db             = new IndividualPartBModel();
            List <Assignments>   assignmentList = db.Assignments.ToList();

            HelperDB.showDbByType(assignmentList);
            int         listPosition = Helper.menuSelectionChecker(assignmentList.Count, false) - 1;
            Assignments assignment   = assignmentList[listPosition];

            return(assignment);
        }
        public static Students chooseStudent()
        {
            IndividualPartBModel db          = new IndividualPartBModel();
            List <Students>      studentList = db.Students.OrderBy(x => x.lastName).ToList();

            HelperDB.showDbByType(studentList);
            int      listPosition = Helper.menuSelectionChecker(studentList.Count, false) - 1;
            Students student      = studentList[listPosition];

            return(student);
        }
        public static Trainers chooseTrainer()
        {
            IndividualPartBModel db          = new IndividualPartBModel();
            List <Trainers>      trainerList = db.Trainers.OrderBy(x => x.lastName).ToList();

            HelperDB.showDbByType(trainerList);
            int      listPosition = Helper.menuSelectionChecker(trainerList.Count, false) - 1;
            Trainers trainer      = trainerList[listPosition];

            return(trainer);
        }
        public static Courses chooseCourse()
        {
            IndividualPartBModel db         = new IndividualPartBModel();
            List <Courses>       courseList = db.Courses.ToList();

            HelperDB.showDbByType(courseList);
            int     listPosition = Helper.menuSelectionChecker(courseList.Count, false) - 1;
            Courses course       = courseList[listPosition];

            return(course);
        }
Ejemplo n.º 6
0
        public static menuIDs trainertMenu()
        {
            //menuID = "130";
            Console.WriteLine("Trainer menu\n");
            Console.WriteLine("Please choose what you want to do:\n" +
                              "1. back\n" +
                              "2. add a new trainer\n" +
                              "3. see all trainers\n" +
                              "4. assign a trainer to a course\n" +
                              "5. see all the connections of all trainers\n" +
                              "EXIT to exit program\n");

            int selection = Helper.menuSelectionChecker(5, true);

            menuIDs IDselect = menuIDs.trainertMenu;

            switch (selection)
            {
            case 1:
                IDselect = menuIDs.centralMenu;
                break;

            case 2:
                ProjectHelper.addNew(availableTypes.Trainer);
                break;

            case 3:
                IndividualPartBModel db = new IndividualPartBModel();
                HelperDB.showDbByType(db.Trainers.ToList());
                break;

            case 4:
                ProjectHelper.addToCourse(availableTypes.Trainer);
                break;

            case 5:
                ProjectHelper.showAllConnections(availableTypes.Trainer);
                break;

            default:
                IDselect = menuIDs.exit;
                break;
            }
            if (selection == 3 || selection == 5)
            {
                Console.WriteLine("Please press any key to continue.");
                Console.ReadKey();
            }
            return(IDselect);
        }
Ejemplo n.º 7
0
        public static menuIDs studentMenu()
        {
            //menuID = "120";
            Console.WriteLine("Student menu\n");
            Console.WriteLine("Please choose what you want to do:\n" +
                              "1. back\n" +
                              "2. add a new student\n" +
                              "3. see all students\n" +
                              "4. see infos about students\n" +
                              "5. add a course to a student\n" +
                              "EXIT to exit program\n");

            int selection = Helper.menuSelectionChecker(5, true);

            menuIDs IDselect = menuIDs.studentMenu;

            switch (selection)
            {
            case 1:
                IDselect = menuIDs.centralMenu;
                break;

            case 2:
                ProjectHelper.addNew(availableTypes.Student);
                break;

            case 3:
                IndividualPartBModel db = new IndividualPartBModel();
                HelperDB.showDbByType(db.Students.ToList());
                break;

            case 4:
                IDselect = menuIDs.infoStudentMenu;
                break;

            case 5:
                ProjectHelper.addToCourse(availableTypes.Student);
                break;

            default:
                IDselect = menuIDs.exit;
                break;
            }
            if (selection == 3)
            {
                Console.WriteLine("Please press any key to continue.");
                Console.ReadKey();
            }
            return(IDselect);
        }
Ejemplo n.º 8
0
        public static menuIDs centralMenu()
        {
            Console.WriteLine("Welcome to our school!!");
            //menuID = "100";
            Console.WriteLine("\nPlease choose what you want to do:\n" +
                              "1. Courses\n" +
                              "2. Students\n" +
                              "3. Trainers\n" +
                              "4. Assignments\n" +
                              "EXIT to exit program\n");

            int selection;

            selection = Helper.menuSelectionChecker(4, true);

            menuIDs IDselect = menuIDs.centralMenu;

            switch (selection)
            {
            case 1:
                IDselect = menuIDs.courseMenu;
                break;

            case 2:
                IDselect = menuIDs.studentMenu;
                break;

            case 3:
                IDselect = menuIDs.trainertMenu;
                break;

            case 4:
                IDselect = menuIDs.assignmentMenu;
                break;

            default:
                IDselect = menuIDs.exit;
                break;
            }
            IndividualPartBModel db = new IndividualPartBModel();

            if (db.Courses.Count() == 0 && selection != -1)
            {
                IDselect = menuIDs.addFirstCourseMenu;
            }
            return(IDselect);
        }
Ejemplo n.º 9
0
        public static void showStudentsWithMultipleCourses()
        {
            IndividualPartBModel db = new IndividualPartBModel();
            int counter             = 0;

            Console.WriteLine("The students with multiple courses are:\n");
            foreach (Students item in db.Students.ToList())
            {
                if (item.Courses.Count() > 1)
                {
                    counter++;
                    show(item, ("  " + counter + ". ").ToString());
                }
            }
            if (counter == 0)
            {
                Console.WriteLine("None of the students has multiple courses.");
            }
        }
Ejemplo n.º 10
0
        public static void showAssignmentPerCoursePerStudentt()
        {
            IndividualPartBModel db = new IndividualPartBModel();

            if (db.Assignments.Count() > 0)
            {
                foreach (Courses course in db.Courses.ToList())
                {
                    show(course, "\nCourse: ");
                    foreach (Assignments assignment in course.Assignments)
                    {
                        assignment.showConnections(availableTypes.Student, true);
                    }
                }
            }
            else
            {
                Console.WriteLine("There no assignment yet.");
            }
        }
        public static void showStudentInfo(availableTypes typeToShow)
        {
            IndividualPartBModel db = new IndividualPartBModel();

            if (!(db.Students.Count() > 0))
            {
                Console.WriteLine("You don't have any students yet.\nWould you like to add a new student? (y/n)");
                if (Helper.yesInput())
                {
                    addNew(availableTypes.Student);
                }
            }
            else
            {
                do
                {
                    Console.WriteLine("\nPlease choose the student you want to see his {0}.", typeToShow);
                    Students student = chooseStudent();
                    student.showConnections(typeToShow, true);
                    Console.WriteLine("\nWould you like to see the {0}s of another Student? (y/n)", typeToShow);
                } while (Helper.yesInput());
            }
        }
        public static void showAssignmentDates()
        {
            IndividualPartBModel db = new IndividualPartBModel();

            do
            {
                List <Assignments> assignmentsToSubmit = new List <Assignments>();
                Console.WriteLine("Please give a date to see if there are any assignments to be submitted.");
                DateTime dt      = Helper.validDateTimeInput();
                DateTime startDt = Helper.startOfCalendarWeek(dt);
                DateTime endDt   = startDt.AddDays(6);
                foreach (Assignments assignment in db.Assignments.ToList())
                {
                    if (assignment.subDateTime >= startDt && assignment.subDateTime <= endDt)
                    {
                        assignmentsToSubmit.Add(assignment);
                    }
                }
                Console.WriteLine("\nAssignments to be submitted between {0} and {1} :\n", startDt.ToString("dd/MM/yyyy"), endDt.ToString("dd/MM/yyyy"));
                if (assignmentsToSubmit.Count() == 0)
                {
                    Console.WriteLine("None assignment.");
                }
                else
                {
                    int assignmentCounter = 1;
                    foreach (Assignments assignment in assignmentsToSubmit)
                    {
                        HelperDB.show(assignment, assignmentCounter + ". ");
                        Console.WriteLine("\nStudents:");
                        assignment.showConnections(availableTypes.Student, false);
                        assignmentCounter++;
                    }
                }
                Console.WriteLine("\nWould you like to check another Date? (y/n)");
            } while (Helper.yesInput());
        }
Ejemplo n.º 13
0
        static bool existsInDb <T>(T value)
        {
            IndividualPartBModel db = new IndividualPartBModel();
            bool flag = false;

            switch (value)
            {
            case Courses course:
                var cList = db.Courses.Where(item => item.title.Equals(course.title, StringComparison.OrdinalIgnoreCase) && item.stream.Equals(course.stream, StringComparison.OrdinalIgnoreCase) && item.type.Equals(course.type, StringComparison.OrdinalIgnoreCase));
                if (cList.Count() > 0)
                {
                    if (cList.Count() > 1)
                    {
                        Console.WriteLine("WARNING!! You have doubles.");
                    }
                    Console.WriteLine("The Course already exists and cannot be added again.");
                    flag = true;
                }
                break;

            case Trainers trainer:
                var tList = db.Trainers.Where(item => item.firstName.Equals(trainer.firstName, StringComparison.OrdinalIgnoreCase) && item.lastName.Equals(trainer.lastName, StringComparison.OrdinalIgnoreCase) && item.subject.Equals(trainer.subject, StringComparison.OrdinalIgnoreCase));
                if (tList.Count() > 0)
                {
                    if (tList.Count() > 1)
                    {
                        Console.WriteLine("WARNING!! You have doubles.");
                    }
                    Console.WriteLine("This Trainer already exists and cannot be added again.");
                    flag = true;
                }
                break;

            case Students student:
                var sList = db.Students.Where(item => item.firstName.Equals(student.firstName, StringComparison.OrdinalIgnoreCase) && item.lastName.Equals(student.lastName, StringComparison.OrdinalIgnoreCase) && item.dateOfBirth == student.dateOfBirth);
                if (sList.Count() > 0)
                {
                    if (sList.Count() > 1)
                    {
                        Console.WriteLine("WARNING!! You have doubles.");
                    }
                    Console.WriteLine("This Student already exists and cannot be added again.");
                    flag = true;
                }
                break;

            case Assignments assignment:
                var aList = db.Assignments.Where(item => item.title.Equals(assignment.title, StringComparison.OrdinalIgnoreCase) && item.description.Equals(assignment.description, StringComparison.OrdinalIgnoreCase) && item.subDateTime == assignment.subDateTime);
                if (aList.Count() > 0)
                {
                    if (aList.Count() > 1)
                    {
                        Console.WriteLine("WARNING!! You have doubles.");
                    }
                    Console.WriteLine("This Assignment already exists and cannot be added again.");
                    flag = true;
                }
                break;

            default:
                Console.WriteLine("The DataBase doesn't support {0}.", value.GetType().Name);
                break;
            }
            return(flag);
        }
Ejemplo n.º 14
0
        public static void addToDb <T>(T value)
        {
            IndividualPartBModel db = new IndividualPartBModel();

            switch (value)
            {
            case Courses course:
                if (!existsInDb(course))
                {
                    db.Courses.Add(course);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch
                    {
                        Console.WriteLine("Something went wrong!");
                    }
                    Console.WriteLine("The {0} was succefully added.", value.GetType().Name);
                }
                break;

            case Trainers trainer:
                if (!existsInDb(trainer))
                {
                    db.Trainers.Add(trainer);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch
                    {
                        Console.WriteLine("Something went wrong!");
                    }
                    Console.WriteLine("The {0} was succefully added.", value.GetType().Name);
                }
                break;

            case Students student:
                if (!existsInDb(student))
                {
                    db.Students.Add(student);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch
                    {
                        Console.WriteLine("Something went wrong!");
                    }
                    Console.WriteLine("The {0} was succefully added.", value.GetType().Name);
                }
                break;

            case Assignments assignment:
                if (!existsInDb(assignment))
                {
                    db.Assignments.Add(assignment);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch
                    {
                        Console.WriteLine("Something went wrong!");
                    }
                    Console.WriteLine("The {0} was succefully added.", value.GetType().Name);
                }
                break;

            default:
                Console.WriteLine("The DataBase doesn't support {0}.", value.GetType().Name);
                break;
            }
        }
        public static void addToCourse(availableTypes typeToAdd)
        {
            IndividualPartBModel db = new IndividualPartBModel();

            Console.WriteLine("\nPlease choose the course you want to add the {0}.\n", typeToAdd);
            Courses course        = chooseCourse();
            bool    emptyListFlag = true;

            switch (typeToAdd)
            {
            case availableTypes.Trainer:
                emptyListFlag = db.Trainers.Count() > 0 ? false : true;
                break;

            case availableTypes.Student:
                emptyListFlag = db.Students.Count() > 0 ? false : true;
                break;

            case availableTypes.Assignment:
                emptyListFlag = db.Assignments.Count() > 0 ? false : true;
                break;
            }
            if (emptyListFlag)
            {
                Console.WriteLine("You don't have any {0} yet.\nWould you like to add a new {1}? (y/n)", typeToAdd, typeToAdd);
                if (Helper.yesInput())
                {
                    addNewLoop(typeToAdd, course);
                }
            }
            else
            {
                Console.WriteLine("\nPlease choose the {0} you want to add the Course.\n", typeToAdd);
                do
                {
                    switch (typeToAdd)
                    {
                    case availableTypes.Trainer:
                        Trainers trainer = chooseTrainer();
                        course.addToCourse(trainer);
                        break;

                    case availableTypes.Student:
                        Students student = chooseStudent();
                        course.addToCourse(student);
                        break;

                    case availableTypes.Assignment:
                        Assignments assignment = chooseAssignment();
                        if (assignment.subDateTime < course.start_date || assignment.subDateTime > course.end_date)
                        {
                            Console.WriteLine("The submit date of the assignment is out of range of the dates of the course.\nAre you sure you want to add the assignment? (y/n)");
                            if (Helper.yesInput())
                            {
                                course.addToCourse(assignment);
                            }
                        }
                        else
                        {
                            course.addToCourse(assignment);
                        }
                        break;
                    }
                    Console.WriteLine("\nWould you like to add another {0} to the course? (y/n)", typeToAdd);
                } while (Helper.yesInput());
            }
        }
        public static void showAllConnections(availableTypes typeToShow)
        {
            IndividualPartBModel db = new IndividualPartBModel();
            bool emptyListFlag      = true;

            switch (typeToShow)
            {
            case availableTypes.Course:
                emptyListFlag = db.Courses.Count() > 0 ? false : true;
                break;

            case availableTypes.Trainer:
                emptyListFlag = db.Trainers.Count() > 0 ? false : true;
                break;

            case availableTypes.Student:
                emptyListFlag = db.Students.Count() > 0 ? false : true;
                break;

            case availableTypes.Assignment:
                emptyListFlag = db.Assignments.Count() > 0 ? false : true;
                break;
            }
            if (emptyListFlag)
            {
                Console.WriteLine("\nThere are no {0}s yet.", typeToShow);
            }
            switch (typeToShow)
            {
            case availableTypes.Course:
                foreach (Courses course in db.Courses.ToList())
                {
                    course.connectionsAnalysis();
                    Console.WriteLine(". . . . . . . . . . . . . . . . . . . .");
                }
                break;

            case availableTypes.Trainer:
                foreach (Trainers trainer in db.Trainers.ToList())
                {
                    trainer.connectionsAnalysis();
                    Console.WriteLine(". . . . . . . . . . . . . . . . . . . .");
                }
                break;

            case availableTypes.Student:
                foreach (Students student in db.Students.ToList())
                {
                    student.connectionsAnalysis();
                    Console.WriteLine(". . . . . . . . . . . . . . . . . . . .");
                }
                break;

            case availableTypes.Assignment:
                foreach (Assignments assignment in db.Assignments.ToList())
                {
                    assignment.connectionsAnalysis();
                    Console.WriteLine(". . . . . . . . . . . . . . . . . . . .");
                }
                break;

            default:
                Console.WriteLine("The DataBase doesn't support {0} connections.", typeToShow);
                break;
            }
        }