Ejemplo n.º 1
0
        public static void Initialize(SchoolContext context)
        {
            //context.Database.EnsureCreated();
            //The above line is not needed after we start using MIGRATIONS

            // Look for any students.
            if (context.Students.Any())
            {
                return;   // DB has been seeded
            }

            var students = new Student[]
            {
                new Student {
                    FirstName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2019-09-01")
                },
                new Student {
                    FirstName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2017-09-01")
                },
                new Student {
                    FirstName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2018-09-01")
                },
                new Student {
                    FirstName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2017-09-01")
                },
                new Student {
                    FirstName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2017-09-01")
                },
                new Student {
                    FirstName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2016-09-01")
                },
                new Student {
                    FirstName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2018-09-01")
                },
                new Student {
                    FirstName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2019-09-01")
                }
            };

            context.Students.AddRange(students);
            context.SaveChanges();

            var instructors = new Instructor[]
            {
                new Instructor {
                    FirstName = "Kim", LastName = "Abercrombie",
                    HireDate  = DateTime.Parse("1995-03-11")
                },
                new Instructor {
                    FirstName = "Fadi", LastName = "Fakhouri",
                    HireDate  = DateTime.Parse("2002-07-06")
                },
                new Instructor {
                    FirstName = "Roger", LastName = "Harui",
                    HireDate  = DateTime.Parse("1998-07-01")
                },
                new Instructor {
                    FirstName = "Candace", LastName = "Kapoor",
                    HireDate  = DateTime.Parse("2001-01-15")
                },
                new Instructor {
                    FirstName = "Roger", LastName = "Zheng",
                    HireDate  = DateTime.Parse("2004-02-12")
                }
            };

            context.Instructors.AddRange(instructors);
            context.SaveChanges();

            var officeAssignments = new OfficeAssignment[]
            {
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID,
                    Location     = "Smith 17"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID,
                    Location     = "Gowan 27"
                },
                new OfficeAssignment {
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID,
                    Location     = "Thompson 304"
                },
            };

            context.OfficeAssignments.AddRange(officeAssignments);
            context.SaveChanges();

            var departments = new Department[]
            {
                new Department {
                    Name         = "English", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
                new Department {
                    Name         = "Mathematics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new Department {
                    Name         = "Engineering", Budget = 350000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new Department {
                    Name         = "Economics", Budget = 100000,
                    StartDate    = DateTime.Parse("2007-09-01"),
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                }
            };

            context.Departments.AddRange(departments);
            context.SaveChanges();

            var courses = new Course[]
            {
                new Course {
                    CourseID     = 1050, Title = "Chemistry", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Engineering").DepartmentID
                },
                new Course {
                    CourseID     = 4022, Title = "Microeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 4041, Title = "Macroeconomics", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                },
                new Course {
                    CourseID     = 1045, Title = "Calculus", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 3141, Title = "Trigonometry", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                },
                new Course {
                    CourseID     = 2021, Title = "Composition", Credits = 3,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
                new Course {
                    CourseID     = 2042, Title = "Literature", Credits = 4,
                    DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                },
            };

            context.Courses.AddRange(courses);
            context.SaveChanges();

            //define the below table only after creating the courses table
            var courseInstructors = new CourseAssignment[]
            {
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Calculus").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Composition").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
                new CourseAssignment {
                    CourseID     = courses.Single(c => c.Title == "Literature").CourseID,
                    InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                },
            };

            context.CourseAssignments.AddRange(courseInstructors);
            context.SaveChanges();


            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.A
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.C
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alexander").ID,
                    CourseID  = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Calculus").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Trigonometry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Alonso").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anand").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Anand").ID,
                    CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Barzdukas").ID,
                    CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Li").ID,
                    CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                    Grade     = Grade.B
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Justice").ID,
                    CourseID  = courses.Single(c => c.Title == "Literature").CourseID,
                    Grade     = Grade.B
                }
            };

            foreach (Enrollment e in enrollments)
            {
                var enrollmentInDataBase = context.Enrollments.Where(
                    s =>
                    s.Student.ID == e.StudentID &&
                    s.Course.CourseID == e.CourseID).SingleOrDefault();
                if (enrollmentInDataBase == null)
                {
                    context.Enrollments.Add(e);
                }
            }
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new SchoolContext(
                       serviceProvider.GetRequiredService <DbContextOptions <SchoolContext> >()))
            {
                // Look for any movies.
                if (context.Students.Any())
                {
                    return;   // DB has been seeded
                }

                var students = new Student[]
                {
                    new Student {
                        FirstMidName   = "Carson", LastName = "Alexander",
                        EnrollmentDate = DateTime.Parse("2010-09-01")
                    },
                    new Student {
                        FirstMidName   = "Meredith", LastName = "Alonso",
                        EnrollmentDate = DateTime.Parse("2012-09-01")
                    },
                    new Student {
                        FirstMidName   = "Arturo", LastName = "Anand",
                        EnrollmentDate = DateTime.Parse("2013-09-01")
                    },
                    new Student {
                        FirstMidName   = "Gytis", LastName = "Barzdukas",
                        EnrollmentDate = DateTime.Parse("2012-09-01")
                    },
                    new Student {
                        FirstMidName   = "Yan", LastName = "Li",
                        EnrollmentDate = DateTime.Parse("2012-09-01")
                    },
                    new Student {
                        FirstMidName   = "Peggy", LastName = "Justice",
                        EnrollmentDate = DateTime.Parse("2011-09-01")
                    },
                    new Student {
                        FirstMidName   = "Laura", LastName = "Norman",
                        EnrollmentDate = DateTime.Parse("2013-09-01")
                    },
                    new Student {
                        FirstMidName   = "Nino", LastName = "Olivetto",
                        EnrollmentDate = DateTime.Parse("2005-09-01")
                    }
                };

                foreach (Student s in students)
                {
                    context.Students.Add(s);
                }
                context.SaveChanges();

                var instructors = new Instructor[]
                {
                    new Instructor {
                        FirstMidName = "Kim", LastName = "Abercrombie",
                        HireDate     = DateTime.Parse("1995-03-11")
                    },
                    new Instructor {
                        FirstMidName = "Fadi", LastName = "Fakhouri",
                        HireDate     = DateTime.Parse("2002-07-06")
                    },
                    new Instructor {
                        FirstMidName = "Roger", LastName = "Harui",
                        HireDate     = DateTime.Parse("1998-07-01")
                    },
                    new Instructor {
                        FirstMidName = "Candace", LastName = "Kapoor",
                        HireDate     = DateTime.Parse("2001-01-15")
                    },
                    new Instructor {
                        FirstMidName = "Roger", LastName = "Zheng",
                        HireDate     = DateTime.Parse("2004-02-12")
                    }
                };

                foreach (Instructor i in instructors)
                {
                    context.Instructors.Add(i);
                }
                context.SaveChanges();

                var departments = new Department[]
                {
                    new Department {
                        Name         = "English", Budget = 350000,
                        StartDate    = DateTime.Parse("2007-09-01"),
                        InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                    },
                    new Department {
                        Name         = "Mathematics", Budget = 100000,
                        StartDate    = DateTime.Parse("2007-09-01"),
                        InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                    },
                    new Department {
                        Name         = "Engineering", Budget = 350000,
                        StartDate    = DateTime.Parse("2007-09-01"),
                        InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                    },
                    new Department {
                        Name         = "Economics", Budget = 100000,
                        StartDate    = DateTime.Parse("2007-09-01"),
                        InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                    }
                };

                foreach (Department d in departments)
                {
                    context.Departments.Add(d);
                }
                context.SaveChanges();

                var courses = new Course[]
                {
                    new Course {
                        CourseID     = 1050, Title = "Chemistry", Credits = 3,
                        DepartmentID = departments.Single(s => s.Name == "Engineering").DepartmentID
                    },
                    new Course {
                        CourseID     = 4022, Title = "Microeconomics", Credits = 3,
                        DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                    },
                    new Course {
                        CourseID     = 4041, Title = "Macroeconomics", Credits = 3,
                        DepartmentID = departments.Single(s => s.Name == "Economics").DepartmentID
                    },
                    new Course {
                        CourseID     = 1045, Title = "Calculus", Credits = 4,
                        DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                    },
                    new Course {
                        CourseID     = 3141, Title = "Trigonometry", Credits = 4,
                        DepartmentID = departments.Single(s => s.Name == "Mathematics").DepartmentID
                    },
                    new Course {
                        CourseID     = 2021, Title = "Composition", Credits = 3,
                        DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                    },
                    new Course {
                        CourseID     = 2042, Title = "Literature", Credits = 4,
                        DepartmentID = departments.Single(s => s.Name == "English").DepartmentID
                    },
                };

                foreach (Course c in courses)
                {
                    context.Courses.Add(c);
                }
                context.SaveChanges();

                var officeAssignments = new OfficeAssignment[]
                {
                    new OfficeAssignment {
                        InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID,
                        Location     = "Smith 17"
                    },
                    new OfficeAssignment {
                        InstructorID = instructors.Single(i => i.LastName == "Harui").ID,
                        Location     = "Gowan 27"
                    },
                    new OfficeAssignment {
                        InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID,
                        Location     = "Thompson 304"
                    },
                };

                foreach (OfficeAssignment o in officeAssignments)
                {
                    context.OfficeAssignments.Add(o);
                }
                context.SaveChanges();

                var courseInstructors = new CourseAssignment[]
                {
                    new CourseAssignment {
                        CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                        InstructorID = instructors.Single(i => i.LastName == "Kapoor").ID
                    },
                    new CourseAssignment {
                        CourseID     = courses.Single(c => c.Title == "Chemistry").CourseID,
                        InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                    },
                    new CourseAssignment {
                        CourseID     = courses.Single(c => c.Title == "Microeconomics").CourseID,
                        InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                    },
                    new CourseAssignment {
                        CourseID     = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                        InstructorID = instructors.Single(i => i.LastName == "Zheng").ID
                    },
                    new CourseAssignment {
                        CourseID     = courses.Single(c => c.Title == "Calculus").CourseID,
                        InstructorID = instructors.Single(i => i.LastName == "Fakhouri").ID
                    },
                    new CourseAssignment {
                        CourseID     = courses.Single(c => c.Title == "Trigonometry").CourseID,
                        InstructorID = instructors.Single(i => i.LastName == "Harui").ID
                    },
                    new CourseAssignment {
                        CourseID     = courses.Single(c => c.Title == "Composition").CourseID,
                        InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                    },
                    new CourseAssignment {
                        CourseID     = courses.Single(c => c.Title == "Literature").CourseID,
                        InstructorID = instructors.Single(i => i.LastName == "Abercrombie").ID
                    },
                };

                foreach (CourseAssignment ci in courseInstructors)
                {
                    context.CourseAssignments.Add(ci);
                }
                context.SaveChanges();

                var enrollments = new Enrollment[]
                {
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Alexander").ID,
                        CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                        Grade     = Grade.A
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Alexander").ID,
                        CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                        Grade     = Grade.C
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Alexander").ID,
                        CourseID  = courses.Single(c => c.Title == "Macroeconomics").CourseID,
                        Grade     = Grade.B
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Alonso").ID,
                        CourseID  = courses.Single(c => c.Title == "Calculus").CourseID,
                        Grade     = Grade.B
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Alonso").ID,
                        CourseID  = courses.Single(c => c.Title == "Trigonometry").CourseID,
                        Grade     = Grade.B
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Alonso").ID,
                        CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                        Grade     = Grade.B
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Anand").ID,
                        CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Anand").ID,
                        CourseID  = courses.Single(c => c.Title == "Microeconomics").CourseID,
                        Grade     = Grade.B
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Barzdukas").ID,
                        CourseID  = courses.Single(c => c.Title == "Chemistry").CourseID,
                        Grade     = Grade.B
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Li").ID,
                        CourseID  = courses.Single(c => c.Title == "Composition").CourseID,
                        Grade     = Grade.B
                    },
                    new Enrollment {
                        StudentID = students.Single(s => s.LastName == "Justice").ID,
                        CourseID  = courses.Single(c => c.Title == "Literature").CourseID,
                        Grade     = Grade.B
                    }
                };

                foreach (Enrollment e in enrollments)
                {
                    var enrollmentInDataBase = context.Enrollments.Where(
                        s =>
                        s.Student.ID == e.StudentID &&
                        s.Course.CourseID == e.CourseID).SingleOrDefault();
                    if (enrollmentInDataBase == null)
                    {
                        context.Enrollments.Add(e);
                    }
                }
                context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public static void Initialize(UniversityContext context)
        {
            context.Database.EnsureCreated();


            if (context.Students.Any())
            {
                return;
            }

            var students = new Student[]
            {
                new Student {
                    StudentId       = "1000", FirstName = "Harry", LastName = "Potter", EnrollmentDate = DateTime.Parse("2018-09-01"),
                    AcquiredCredits = 100, CurrentSemestar = 4, EducationLevel = "High School Diploma", ProfilePicture = "https://upload.wikimedia.org/wikipedia/sco/4/44/HarryPotter5poster.jpg"
                },
                new Student {
                    StudentId       = "1001", FirstName = "Hermione", LastName = "Granger", EnrollmentDate = DateTime.Parse("2018-09-01"),
                    AcquiredCredits = 100, CurrentSemestar = 4, EducationLevel = "High School Diploma", ProfilePicture = "https://myhero.com/images/guest/g282317/hero105677/image2.jpg"
                },
                new Student {
                    StudentId       = "1002", FirstName = "Ronald", LastName = "Weasley", EnrollmentDate = DateTime.Parse("2018-09-01"),
                    AcquiredCredits = 100, CurrentSemestar = 4, EducationLevel = "High School Diploma", ProfilePicture = "https://vignette.wikia.nocookie.net/harrypotterfanon/images/5/56/Ron_Weasley_%28Scopatore%29.jpg/revision/latest?cb=20160120050600"
                },
                new Student {
                    StudentId       = "1003", FirstName = "Ginny", LastName = "Weasley", EnrollmentDate = DateTime.Parse("2018-09-01"),
                    AcquiredCredits = 100, CurrentSemestar = 4, EducationLevel = "High School Diploma", ProfilePicture = "https://vignette.wikia.nocookie.net/harrypotter/images/8/8b/Ginny_Weasley_hbp_promo.jpg/revision/latest?cb=20180322181904"
                },
                new Student {
                    StudentId       = "1004", FirstName = "Neville", LastName = "Longbottom", EnrollmentDate = DateTime.Parse("2018-09-01"),
                    AcquiredCredits = 100, CurrentSemestar = 4, EducationLevel = "High School Diploma", ProfilePicture = "https://vignette.wikia.nocookie.net/harrypotter/images/1/10/Neville-promo-pics-neville-longbottom-28261912-390-520.jpg/revision/latest?cb=20140610141612"
                },
                new Student {
                    StudentId       = "1005", FirstName = "Luna", LastName = "Lovegood", EnrollmentDate = DateTime.Parse("2018-09-01"),
                    AcquiredCredits = 100, CurrentSemestar = 4, EducationLevel = "High School Diploma", ProfilePicture = "https://images.ctfassets.net/usf1vwtuqyxm/t6GVMDanqSKGOKaCWi8oi/74b6816d9f913623419b98048ec87d25/LunaLovegood_WB_F5_LunaLovegoodPromoCloseUp_Promo_080615_Port.jpg?fm=jpg"
                },
                new Student {
                    StudentId       = "1006", FirstName = "Draco", LastName = "Malfoy", EnrollmentDate = DateTime.Parse("2018-09-01"),
                    AcquiredCredits = 100, CurrentSemestar = 4, EducationLevel = "High School Diploma", ProfilePicture = "https://vignette.wikia.nocookie.net/hogwarts-life/images/8/82/Draco_Malfoy.jpg/revision/latest?cb=20170112183355"
                },
                new Student {
                    StudentId       = "1007", FirstName = "Cedric", LastName = "Diggory", EnrollmentDate = DateTime.Parse("2018-09-01"),
                    AcquiredCredits = 100, CurrentSemestar = 4, EducationLevel = "High School Diploma", ProfilePicture = "https://images-na.ssl-images-amazon.com/images/I/51-mjy5XsML._AC_.jpg"
                }
            };

            foreach (Student s in students)
            {
                context.Students.Add(s);
            }
            context.SaveChanges();

            // if(context.Teachers.Any()){
            //  return;
            // }
            var teachers = new Teacher[]
            {
                new Teacher {
                    FirstName    = "Severus", LastName = "Snape", Degree = "Doctorate", AcademicRank = "Full professor",
                    OfficeNumber = "304", HireDate = DateTime.Parse("2003-07-01"), ProfilePicture = "https://lh3.googleusercontent.com/proxy/Oz8V-0G0RvI5Emt150FC2_mp2GmYz0CVuacTqiqTz52dE7RugmdMlztlIO42DGhXhCdarepKzOWsS_Lf4rdu26EEf0qZyXedGqPLtDe366i6nIInK65CdU8Tmg"
                },
                new Teacher {
                    FirstName    = "Minerva", LastName = "McGonagall", Degree = "Doctorate", AcademicRank = "Full professor",
                    OfficeNumber = "201", HireDate = DateTime.Parse("2004-08-02"), ProfilePicture = "https://i.pinimg.com/originals/8b/71/30/8b71304ce2660f2943b2639ae2a6ebba.jpg"
                },
                new Teacher {
                    FirstName    = "Albus", LastName = "Dumbledore", Degree = "Doctorate", AcademicRank = "Full professor",
                    OfficeNumber = "804", HireDate = DateTime.Parse("2002-06-05"), ProfilePicture = "https://images.ctfassets.net/usf1vwtuqyxm/1dmmUJzpRcWaUmMOCu8QwO/7e013145694566076d47fd004fd604c2/AlbusDumbledore_WB_F6_DumbledoreSittingInChair_Promo_080615_Port.jpg?fm=jpg"
                },
                new Teacher {
                    FirstName    = "Filius", LastName = "Flitwick", Degree = "Doctorate", AcademicRank = "Full professor",
                    OfficeNumber = "312", HireDate = DateTime.Parse("2003-04-23"), ProfilePicture = "https://images.ctfassets.net/usf1vwtuqyxm/7zwF0icg0kQW2ejGM7mqw2/29f2491ad063a317fb55a6f6c69aecce/flitwich-quiz-image.jpg?fm=jpg"
                },
                new Teacher {
                    FirstName    = "Pomona", LastName = "Sprout", Degree = "Doctorate", AcademicRank = "Full professor",
                    OfficeNumber = "901", HireDate = DateTime.Parse("2005-09-23"), ProfilePicture = "https://vignette.wikia.nocookie.net/hogwarts-life/images/7/7d/HP72-FP-00573.jpg/revision/latest/top-crop/width/360/height/450?cb=20170122163222"
                },
                new Teacher {
                    FirstName    = "Horace", LastName = "Slughorn", Degree = "Doctorate", AcademicRank = "Full professor",
                    OfficeNumber = "134", HireDate = DateTime.Parse("2004-02-12"), ProfilePicture = "https://pbs.twimg.com/media/EAezZ-gXUAU3aD-.jpg"
                },
                new Teacher {
                    FirstName    = "Rubeus", LastName = "Hagrid", Degree = "Doctorate", AcademicRank = "Full professor",
                    OfficeNumber = "784", HireDate = DateTime.Parse("2002-08-16"), ProfilePicture = "https://images-na.ssl-images-amazon.com/images/I/51K6H%2BEhr1L._AC_.jpg"
                }
            };

            foreach (Teacher t in teachers)
            {
                context.Teachers.Add(t);
            }
            context.SaveChanges();

            // if(context.Courses.Any()){
            //   return;
            //}

            var courses = new Course[]
            {
                new Course {
                    CourseID       = 1050, Title = "Potions", Credits = 3, Semester = 4, Programme = "New programme", EducationLevel = "High School Diploma",
                    FirstTeacherId = teachers.Single(s => s.LastName == "Snape").TeacherId, SecondTeacherId = teachers.Single(s => s.LastName == "McGonagall").TeacherId
                },
                new Course {
                    CourseID       = 4022, Title = "History of Magic", Credits = 3, Semester = 4, Programme = "New programme", EducationLevel = "High School Diploma",
                    FirstTeacherId = teachers.Single(s => s.LastName == "Snape").TeacherId, SecondTeacherId = teachers.Single(s => s.LastName == "McGonagall").TeacherId
                },
                new Course {
                    CourseID       = 4041, Title = "Defence Againts the Dark Arts", Credits = 3, Semester = 4, Programme = "New programme", EducationLevel = "High School Diploma",
                    FirstTeacherId = teachers.Single(s => s.LastName == "Dumbledore").TeacherId, SecondTeacherId = teachers.Single(s => s.LastName == "Flitwick").TeacherId
                },
                new Course {
                    CourseID       = 1045, Title = "Care of Magical Creatures", Credits = 3, Semester = 4, Programme = "New programme", EducationLevel = "High School Diploma",
                    FirstTeacherId = teachers.Single(s => s.LastName == "Dumbledore").TeacherId, SecondTeacherId = teachers.Single(s => s.LastName == "Flitwick").TeacherId
                },
                new Course {
                    CourseID       = 3141, Title = "Astronomy", Credits = 4, Semester = 4, Programme = "New programme", EducationLevel = "High School Diploma",
                    FirstTeacherId = teachers.Single(s => s.LastName == "Sprout").TeacherId, SecondTeacherId = teachers.Single(s => s.LastName == "Slughorn").TeacherId
                },
                new Course {
                    CourseID       = 2021, Title = "Flying", Credits = 3, Semester = 4, Programme = "New programme", EducationLevel = "High School Diploma",
                    FirstTeacherId = teachers.Single(s => s.LastName == "Sprout").TeacherId, SecondTeacherId = teachers.Single(s => s.LastName == "Hagrid").TeacherId
                },
                new Course {
                    CourseID       = 2042, Title = "Study of Ancient Runes", Credits = 4, Semester = 4, Programme = "New programme", EducationLevel = "High School Diploma",
                    FirstTeacherId = teachers.Single(s => s.LastName == "Slughorn").TeacherId, SecondTeacherId = teachers.Single(s => s.LastName == "Hagrid").TeacherId
                }
            };

            foreach (Course c in courses)
            {
                context.Courses.Add(c);
            }
            context.SaveChanges();



            var enrollments = new Enrollment[]
            {
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Potter").ID, CourseID = courses.Single(c => c.Title == "Potions").CourseID, Semester = "4", Year = 2,
                    Grade     = 10, SeminalUrl = "abc", ProjectUrl = "ab1", ExamPoints = 100, SeminalPoints = 100, ProjectPoints = 100, AdditionalPoints = 5, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Potter").ID, CourseID = courses.Single(c => c.Title == "History of Magic").CourseID, Semester = "4", Year = 2,
                    Grade     = 9, SeminalUrl = "abd", ProjectUrl = "ab2", ExamPoints = 80, SeminalPoints = 90, ProjectPoints = 100, AdditionalPoints = 0, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Granger").ID, CourseID = courses.Single(c => c.Title == "History of Magic").CourseID, Semester = "4", Year = 2,
                    Grade     = 8, SeminalUrl = "abe", ProjectUrl = "ab3", ExamPoints = 50, SeminalPoints = 80, ProjectPoints = 100, AdditionalPoints = 3, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Granger").ID, CourseID = courses.Single(c => c.Title == "Defence Againts the Dark Arts").CourseID, Semester = "4", Year = 2,
                    Grade     = 7, SeminalUrl = "abf", ProjectUrl = "ab4", ExamPoints = 70, SeminalPoints = 50, ProjectPoints = 50, AdditionalPoints = 2, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.FirstName == "Ronald").ID, CourseID = courses.Single(c => c.Title == "Defence Againts the Dark Arts").CourseID, Semester = "4", Year = 2,
                    Grade     = 6, SeminalUrl = "abg", ProjectUrl = "ab5", ExamPoints = 50, SeminalPoints = 50, ProjectPoints = 50, AdditionalPoints = 5, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.FirstName == "Ronald").ID, CourseID = courses.Single(c => c.Title == "Care of Magical Creatures").CourseID, Semester = "4", Year = 2,
                    Grade     = 6, SeminalUrl = "abh", ProjectUrl = "ab6", ExamPoints = 40, SeminalPoints = 50, ProjectPoints = 60, AdditionalPoints = 3, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.FirstName == "Giny").ID, CourseID = courses.Single(c => c.Title == "Care of Magical Creatures").CourseID, Semester = "4", Year = 2,
                    Grade     = 9, SeminalUrl = "abi", ProjectUrl = "ab7", ExamPoints = 70, SeminalPoints = 100, ProjectPoints = 60, AdditionalPoints = 6, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.FirstName == "Giny").ID, CourseID = courses.Single(c => c.Title == "Astronomy").CourseID, Semester = "4", Year = 2,
                    Grade     = 9, SeminalUrl = "abj", ProjectUrl = "ab8", ExamPoints = 80, SeminalPoints = 90, ProjectPoints = 100, AdditionalPoints = 12, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Longbottom").ID, CourseID = courses.Single(c => c.Title == "Astronomy").CourseID, Semester = "4", Year = 2,
                    Grade     = 6, SeminalUrl = "abk", ProjectUrl = "ab9", ExamPoints = 50, SeminalPoints = 30, ProjectPoints = 40, AdditionalPoints = 8, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Longbottom").ID, CourseID = courses.Single(c => c.Title == "Flying").CourseID, Semester = "4", Year = 2,
                    Grade     = 8, SeminalUrl = "abl", ProjectUrl = "ab10", ExamPoints = 100, SeminalPoints = 50, ProjectPoints = 100, AdditionalPoints = 0, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Lovegood").ID, CourseID = courses.Single(c => c.Title == "Flying").CourseID, Semester = "4", Year = 2,
                    Grade     = 7, SeminalUrl = "abm", ProjectUrl = "ab11", ExamPoints = 70, SeminalPoints = 70, ProjectPoints = 70, AdditionalPoints = 10, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Lovegood").ID, CourseID = courses.Single(c => c.Title == "Study of Ancient Runes").CourseID, Semester = "4", Year = 2,
                    Grade     = 10, SeminalUrl = "abn", ProjectUrl = "ab12", ExamPoints = 100, SeminalPoints = 100, ProjectPoints = 100, AdditionalPoints = 3, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Malfoy").ID, CourseID = courses.Single(c => c.Title == "Study of Ancient Runes").CourseID, Semester = "4", Year = 2,
                    Grade     = 6, SeminalUrl = "abo", ProjectUrl = "ab13", ExamPoints = 50, SeminalPoints = 30, ProjectPoints = 40, AdditionalPoints = 8, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Malfoy").ID, CourseID = courses.Single(c => c.Title == "Defence Againts the Dark Arts").CourseID, Semester = "4", Year = 2,
                    Grade     = 8, SeminalUrl = "abp", ProjectUrl = "ab14", ExamPoints = 100, SeminalPoints = 50, ProjectPoints = 100, AdditionalPoints = 0, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Diggory").ID, CourseID = courses.Single(c => c.Title == "Flying").CourseID, Semester = "4", Year = 2,
                    Grade     = 7, SeminalUrl = "abq", ProjectUrl = "ab15", ExamPoints = 70, SeminalPoints = 70, ProjectPoints = 70, AdditionalPoints = 10, FinishDate = DateTime.Parse("2020-10-01")
                },
                new Enrollment {
                    StudentID = students.Single(s => s.LastName == "Diggory").ID, CourseID = courses.Single(c => c.Title == "Potions").CourseID, Semester = "4", Year = 2,
                    Grade     = 10, SeminalUrl = "abr", ProjectUrl = "ab16", ExamPoints = 100, SeminalPoints = 100, ProjectPoints = 100, AdditionalPoints = 3, FinishDate = DateTime.Parse("2020-10-01")
                }
            };

            foreach (Enrollment e in enrollments)
            {
                context.Enrollments.Add(e);
            }
            context.SaveChanges();


            if (context.AppUser.Any())
            {
                return;
            }

            context.AppUser.AddRange(
                new AppUser
            {
                Name     = "Admin",
                Email    = "*****@*****.**",
                Password = "******"
            }
                );
            context.SaveChanges();
        }