Ejemplo n.º 1
0
        private void Assign(MegaHard cd, Assignment ass)
        {
            List <Course> courselist = cd.Courses.ToList();

            Console.WriteLine("\nAssign Assignment to course:");
            try
            {
                int input = Helper.Assign("Assignment", courselist);
                input = ifInputis0(input, courselist, ass.AssID);

                while (input != 0 && courselist.Where(c => c.CourseID == input).Any(c => c.Assignments.Any(a => a.AssID == ass.AssID)))
                {
                    Console.WriteLine("\nAssignment already exists that course or Assignment Sub Date is sooner than the course Start Date! Choose another:\n");
                    input = Helper.Assign("Assignment", courselist);
                    input = ifInputis0(input, courselist, ass.AssID);

                    if (input == 0)
                    {
                        break;
                    }
                }
                if (input != 0)
                {
                    try
                    {
                        cd.Courses.FirstOrDefault(c => c.CourseID == input).Assignments.Add(ass);
                        cd.SaveChanges();
                    }
                    catch (SqlException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                bool assignAgain = Helper.AssignAgain("Assignment");
                if (assignAgain)
                {
                    Assign(cd, ass);
                }
            }
            catch (Exception)
            {
                //Console.WriteLine(ex.Message);
                Console.Beep();
                Console.WriteLine("Good job! You have unlocked a hidden code block! Please restart!");
            }
        }
Ejemplo n.º 2
0
        private void Assign(MegaHard cd, Trainer tr)
        {
            List <Course> courselist = cd.Courses.ToList();

            Console.WriteLine("\nAssign Trainer to course:");
            try
            {
                int input = Helper.Assign("Trainer", courselist);
                input = ifInputis0(input, courselist, tr.TrainerID);

                while (input != 0 && courselist.Where(c => c.CourseID == input).Any(c => c.Trainers.Any(t => t.TrainerID == tr.TrainerID)))
                {
                    Console.WriteLine("\nTrainer already exists that course! Choose another:\n");
                    input = Helper.Assign("Trainer", courselist);
                    input = ifInputis0(input, courselist, tr.TrainerID);
                    if (input == 0)
                    {
                        break;
                    }
                }
                if (input != 0)
                {
                    try
                    {
                        cd.Courses.FirstOrDefault(c => c.CourseID == input).Trainers.Add(tr);
                        cd.SaveChanges();
                    }
                    catch (SqlException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                bool assignAgain = Helper.AssignAgain("Trainer");
                if (assignAgain)
                {
                    Assign(cd, tr);
                }
            }
            catch (Exception)
            {
                Console.Beep();
                //Console.WriteLine(ex.Message);
                Console.WriteLine("Good job! You have unlocked a hidden code block! Please restart!");
            }
        }
Ejemplo n.º 3
0
        private void Assign(MegaHard cd, Student st)
        {
            List <Course> courselist = cd.Courses.ToList();

            Console.WriteLine("\nAssign Student to course:");
            try
            {
                int input = Helper.Assign("Student", courselist);
                input = ifInputis0(input, courselist, st.StudentID);

                while (input != 0 && courselist.Where(c => c.CourseID == input).Any(c => c.Students.Any(s => s.StudentID == st.StudentID)))
                {
                    Console.WriteLine("\nStudent already exists that course! Choose another:\n");
                    input = Helper.Assign("Student", courselist);
                    input = ifInputis0(input, courselist, st.StudentID);
                    if (input == 0)
                    {
                        break;
                    }
                }
                if (input != 0)
                {
                    try
                    {
                        cd.Courses.FirstOrDefault(c => c.CourseID == input).Students.Add(st);
                        cd.SaveChanges();
                    }
                    catch (SqlException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                bool assignAgain = Helper.AssignAgain("Student");
                if (assignAgain)
                {
                    Assign(cd, st);
                }
            }
            catch (Exception)
            {
                Console.Beep();
                //Console.WriteLine(ex.Message);
                Console.WriteLine("Good job! You have unlocked a hidden code block! Please restart for secret features!");
            }
        }
Ejemplo n.º 4
0
        public void AddCourseToList(Course a, MegaHard cd)
        {
            bool b = cd.Courses.Any(c => c.Title == Title && c.Stream == Stream && c.Type == Type && c.Start_date == Start_date && c.End_date == End_date);

            if (!b)
            {
                try
                {
                    cd.Courses.Add(a);
                    cd.SaveChanges();
                }
                catch (SqlException)
                {
                    Console.WriteLine("All ok");
                }
            }
            else
            {
                Console.WriteLine("Course already exists so this instance is deleted!");
            }
        }
Ejemplo n.º 5
0
        public void AddAssToCourse(Assignment ass, MegaHard cd)
        {
            bool b = cd.Assignments.Any(a => a.Title == Title && a.Description == Description && a.SubDateTime == SubDateTime && a.OralMark == OralMark && a.TotalMark == TotalMark);

            if (!b)
            {
                try
                {
                    cd.Assignments.Add(ass);
                    cd.SaveChanges();
                    Assign(cd, ass);
                }
                catch (SqlException)
                {
                    Console.WriteLine("All ok");
                }
            }
            else
            {
                Console.WriteLine("Assignment already exists so this instance is deleted!");
            }
        }
Ejemplo n.º 6
0
        public void AddTrainerToCourse(Trainer tr, MegaHard cd)
        {
            bool b = cd.Trainers.Any(t => t.FirstName == FirstName && t.LastName == LastName && t.Subject == Subject);

            if (!b)
            {
                try
                {
                    cd.Trainers.Add(tr);
                    cd.SaveChanges();
                    Assign(cd, tr);
                }
                catch (SqlException)
                {
                    Console.WriteLine("All ok");
                }
            }
            else
            {
                Console.WriteLine("Trainer already exists so this instance is deleted!");
            }
        }
Ejemplo n.º 7
0
        public void AddStudentToCourse(Student st, MegaHard cd)
        {
            bool b = cd.Students.Any(s => s.FirstName == FirstName && s.LastName == LastName && s.DateOfBirth == DateOfBirth);

            if (!b)
            {
                try
                {
                    cd.Students.Add(st);
                    cd.SaveChanges();
                    Assign(cd, st);
                }
                catch (SqlException)
                {
                    Console.WriteLine("All ok");
                }
            }
            else
            {
                Console.WriteLine("Student already exists so this instance is deleted!");
            }
        }