Beispiel #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new ProjectContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <ProjectContext> >()))
            {
                if (!context.Clients.Any())
                {
                    context.Clients.AddRange(
                        new Clients
                    {
                        FirstName      = "Marija",
                        LastName       = "Markoska",
                        EnrollmentDate = DateTime.Parse("2017-09-15"),
                        Мembership     = false
                    },
                        new Clients
                    {
                        FirstName      = "Simona",
                        LastName       = "Simonoska",
                        EnrollmentDate = DateTime.Parse("2016-09-15"),
                        Мembership     = true
                    },
                        new Clients
                    {
                        FirstName      = "Aleksandra",
                        LastName       = "Atanasoska",
                        EnrollmentDate = DateTime.Parse("2016-09-15"),
                        Мembership     = true
                    },
                        new Clients
                    {
                        FirstName      = "Andrej",
                        LastName       = "Andreevski",
                        EnrollmentDate = DateTime.Parse("2017-09-15"),
                        Мembership     = true
                    },
                        new Clients
                    {
                        FirstName      = "Angela",
                        LastName       = "Angeloska",
                        EnrollmentDate = DateTime.Parse("2017-09-15"),
                        Мembership     = true
                    },
                        new Clients
                    {
                        FirstName      = "Marko",
                        LastName       = "Markoski",
                        EnrollmentDate = DateTime.Parse("2015-09-15"),
                        Мembership     = true
                    },
                        new Clients
                    {
                        FirstName      = "Stefan",
                        LastName       = "Stefanoski",
                        EnrollmentDate = DateTime.Parse("2018-09-15"),
                        Мembership     = true
                    },
                        new Clients
                    {
                        FirstName      = "Stefani",
                        LastName       = "Stefanoska",
                        EnrollmentDate = DateTime.Parse("2017-09-15"),
                        Мembership     = true
                    }
                        );
                }
                if (!context.Coaches.Any())
                {
                    context.Coaches.AddRange(
                        new Coaches
                    {
                        FirstName   = "Tale",
                        LastName    = "Trajkov",
                        Certificate = true,
                        HireDate    = DateTime.Parse("2010-05-12")
                    },
                        new Coaches
                    {
                        FirstName   = "Viktorija",
                        LastName    = "Ackova",
                        Certificate = true,
                        HireDate    = DateTime.Parse("2009-10-25")
                    },
                        new Coaches
                    {
                        FirstName   = "Vladimir",
                        LastName    = "Petrovski",
                        Certificate = true,
                        HireDate    = DateTime.Parse("2012-10-10")
                    },
                        new Coaches
                    {
                        FirstName   = "Simona",
                        LastName    = "Baseska",
                        Certificate = true,
                        HireDate    = DateTime.Parse("2007-03-20")
                    },
                        new Coaches
                    {
                        FirstName   = "Marko",
                        LastName    = "Velevackovski",
                        Certificate = false,
                        HireDate    = DateTime.Parse("2015-09-06")
                    },
                        new Coaches
                    {
                        FirstName   = "Lazar",
                        LastName    = "Nikolov",
                        Certificate = true,
                        HireDate    = DateTime.Parse("2016-06-10")
                    },
                        new Coaches
                    {
                        FirstName   = "Kristijan",
                        LastName    = "Kimovski",
                        Certificate = true,
                        HireDate    = DateTime.Parse("2012-07-10")
                    }
                        );
                }
                if (!context.Programs.Any())
                {
                    context.Programs.AddRange(
                        new Programs
                    {
                        Name     = "InstaBOOTY",
                        Payment  = "50$",
                        Duration = "6 meseci",
                        CoachId  = context.Coaches.Single(d => d.FirstName == "Tale" && d.LastName == "Trajkov").Id
                    },
                        new Programs
                    {
                        Name     = "InstaFIT",
                        Payment  = "30$",
                        Duration = "3 meseci",
                        CoachId  = context.Coaches.Single(d => d.FirstName == "Viktorija" && d.LastName == "Ackova").Id
                    },
                        new Programs
                    {
                        Name     = "HIIT",
                        Payment  = "100$",
                        Duration = "6 meseci",
                        CoachId  = context.Coaches.Single(d => d.FirstName == "Vladimir" && d.LastName == "Petrovski").Id
                    },
                        new Programs
                    {
                        Name     = "FULL BODY",
                        Payment  = "50$",
                        Duration = "2 meseci",
                        CoachId  = context.Coaches.Single(d => d.FirstName == "Simona" && d.LastName == "Baseska").Id
                    },
                        new Programs
                    {
                        Name     = "SPLIT BODY",
                        Payment  = "30$",
                        Duration = "1 meseci",
                        CoachId  = context.Coaches.Single(d => d.FirstName == "Lazar" && d.LastName == "Nikolov").Id
                    },

                        new Programs
                    {
                        Name     = "BODY PERFECTION",
                        Payment  = "80$",
                        Duration = "3 meseci",
                        CoachId  = context.Coaches.Single(d => d.FirstName == "Marko" && d.LastName == "Velevackovski").Id
                    }
                        );
                }



                if (!context.Enrollment.Any())
                {
                    context.Enrollment.AddRange(
                        new Enrollment
                    {
                        ProgramId     = context.Programs.Single(x => x.Name == "BODY PERFECTION").Id,
                        ClientId      = context.Clients.Single(x => x.FirstName == "Stefan").Id,
                        InitialWeight = 87,
                        FinalWeight   = 70,
                        FinishDate    = DateTime.Parse("2020-01-28")
                    },
                        new Enrollment
                    {
                        ProgramId     = context.Programs.Single(x => x.Name == "SPLIT BODY").Id,
                        ClientId      = context.Clients.Single(x => x.FirstName == "Stefani").Id,
                        InitialWeight = 55,
                        FinalWeight   = 60,
                        FinishDate    = DateTime.Parse("2019-06-28")
                    },
                        new Enrollment
                    {
                        ProgramId     = context.Programs.Single(x => x.Name == "FULL BODY").Id,
                        ClientId      = context.Clients.Single(x => x.FirstName == "Marko").Id,
                        InitialWeight = 60,
                        FinalWeight   = 55,
                        FinishDate    = DateTime.Parse("2019-06-06")
                    },
                        new Enrollment
                    {
                        ProgramId     = context.Programs.Single(x => x.Name == "InstaBOOTY").Id,
                        ClientId      = context.Clients.Single(x => x.FirstName == "Aleksandra").Id,
                        InitialWeight = 100,
                        FinalWeight   = 80,
                        FinishDate    = DateTime.Parse("2020-01-20")
                    },
                        new Enrollment
                    {
                        ProgramId     = context.Programs.Single(x => x.Name == "HIIT").Id,
                        ClientId      = context.Clients.Single(x => x.FirstName == "Andrej").Id,
                        InitialWeight = 85,
                        FinalWeight   = 73,
                        FinishDate    = DateTime.Parse("2019-01-25")
                    },
                        new Enrollment
                    {
                        ProgramId     = context.Programs.Single(x => x.Name == "InstaFIT").Id,
                        ClientId      = context.Clients.Single(x => x.FirstName == "Marija").Id,
                        InitialWeight = 130,
                        FinalWeight   = 95,
                        FinishDate    = DateTime.Parse("2019-02-01")
                    }
                        );
                }
                context.SaveChanges();
            }
        }
Beispiel #2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new ProjectContext(
                       serviceProvider.GetRequiredService
                       <DbContextOptions <ProjectContext> >()))
            {
                // Look for any movies.
                if (context.Category.Any())
                {
                    return;   // DB has been seeded
                }
                context.Category.AddRange
                (
                    new Category
                {
                    CategoryName = "Hiking"
                },

                    new Category
                {
                    CategoryName = "City"
                },

                    new Category
                {
                    CategoryName = "Museum"
                },

                    new Category
                {
                    CategoryName = "Diving"
                },

                    new Category
                {
                    CategoryName = "Off Road"
                }
                );

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

                context.Tour.AddRange
                (
                    new Tour
                {
                    TourTitle    = "Hiking in Himalayas",
                    ToursStartAt = DateTime.Parse("2020-09-15"),
                    ToursEndAt   = DateTime.Parse("2020-09-25"),
                    CategoryId   = 1
                },

                    new Tour
                {
                    TourTitle    = "10 Days At Prague",
                    ToursStartAt = DateTime.Parse("2020-10-20"),
                    ToursEndAt   = DateTime.Parse("2020-10-30"),
                    CategoryId   = 2
                }
                );
                context.SaveChanges();
            }
        }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new ProjectContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <ProjectContext> >()))
            {
                // Look for any movies.
                if (context.Student.Any() || context.Teacher.Any() || context.Course.Any())
                {
                    return;   // DB has been seeded
                }

                context.Student.AddRange(

                    new Student
                {     /*Id = 1, */
                    StudentId       = "233/2018",
                    FirstName       = "Anna",
                    LastName        = "Park",
                    EnrollmentDate  = DateTime.Parse("2020-7-6"),
                    AcquiredCredits = 132,
                    CurrentSemestar = 6,
                    EducationLevel  = "Associate degree",
                    ProfilePicture  = "https://s23527.pcdn.co/wp-content/uploads/2019/12/Downside-Up-745x449.jpg.optimal.jpg"
                },
                    new Student
                {      /*Id = 2, */
                    StudentId       = "255/2018",
                    FirstName       = "Mary",
                    LastName        = "Johnson",
                    EnrollmentDate  = DateTime.Parse("2020-3-10"),
                    AcquiredCredits = 186,
                    CurrentSemestar = 7,
                    EducationLevel  = "Bachelor's degree",
                    ProfilePicture  = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzx__blVU5FWJAUCU4d9-E095_n3Fgy1tuxA&usqp=CAU"
                },
                    new Student
                {       /*Id = 3, */
                    StudentId       = "332/2014",
                    FirstName       = "Gale",
                    LastName        = "Thompson",
                    EnrollmentDate  = DateTime.Parse("2021-5-12"),
                    AcquiredCredits = 212,
                    CurrentSemestar = 8,
                    EducationLevel  = "Master's degree",
                    ProfilePicture  = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQSXW4UPcJXYURYqTwvz3YI06eM1gNeQbo-HQ&usqp=CAU"
                }
                    );
                context.SaveChanges();

                context.Teacher.AddRange(
                    new Teacher
                {    /*Id = 1, */
                    FirstName      = "Tom",
                    LastName       = "Hale",
                    Degree         = "Doctoral Degree",
                    AcademicRank   = "Associate Professor",
                    OfficeNumber   = "107",
                    HireDate       = DateTime.Parse("2012-9-5"),
                    ProfilePicture = "https://www.planetware.com/wpimages/2020/02/france-in-pictures-beautiful-places-to-photograph-eiffel-tower.jpg"
                },
                    new Teacher
                {    /*Id = 2, */
                    FirstName      = "Ashley",
                    LastName       = "Mitchell",
                    Degree         = "Professional Degree",
                    AcademicRank   = "Full Professor",
                    OfficeNumber   = "304",
                    HireDate       = DateTime.Parse("2015-10-11"),
                    ProfilePicture = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSff8JL9ALjQrQ11mS8MNLOGgyOXjRTJEckCA&usqp=CAU"
                },
                    new Teacher
                {     /*Id = 3, */
                    FirstName      = "Taylor",
                    LastName       = "Smith",
                    Degree         = "Master's Degree",
                    AcademicRank   = "Assistant Professor",
                    OfficeNumber   = "106",
                    HireDate       = DateTime.Parse("2020-4-2"),
                    ProfilePicture = " https://cdn.pixabay.com/photo/2016/12/16/15/25/christmas-1911637__340.jpg"
                }


                    );
                context.SaveChanges();


                context.Course.AddRange(
                    new Course
                {     /*Id = 1, */
                    Title           = "Proggraming and Algorithms",
                    Credits         = 6,
                    Semester        = 1,
                    Programme       = "Telecommunications and Information Technology",
                    EducationLevel  = "Associate degree",
                    FirstTeacherID  = context.Teacher.Single(d => d.FirstName == "Taylor" && d.LastName == "Smith").Id,
                    SecondTeacherID = context.Teacher.Single(d => d.FirstName == "Tom" && d.LastName == "Hale").Id
                },
                    new Course
                {     /*Id = 2, */
                    Title           = "Information Theory",
                    Credits         = 6,
                    Semester        = 3,
                    Programme       = "Telecommunications and Information Technology",
                    EducationLevel  = "Master's degree",
                    FirstTeacherID  = context.Teacher.Single(d => d.FirstName == "Taylor" && d.LastName == "Smith").Id,
                    SecondTeacherID = context.Teacher.Single(d => d.FirstName == "Ashley" && d.LastName == "Mitchell").Id
                },
                    new Course
                {       /*Id = 3, */
                    Title           = "Signals and Systems",
                    Credits         = 6,
                    Semester        = 3,
                    Programme       = "Telecommunications and Information Technology",
                    EducationLevel  = "Bachelor's degree",
                    FirstTeacherID  = context.Teacher.Single(d => d.FirstName == "Tom" && d.LastName == "Hale").Id,
                    SecondTeacherID = context.Teacher.Single(d => d.FirstName == "Ashley" && d.LastName == "Mitchell").Id
                }

                    );
                context.SaveChanges();


                context.SaveChanges();

                context.Enrollment.AddRange(
                    new Enrollment
                {
                    CourseId         = 1,
                    StudentId        = 2,
                    Semester         = 4,
                    Year             = 2,
                    Grade            = 4,
                    SeminarUrl       = "https://",
                    ProjectUrl       = "https://",
                    ExamPoints       = 70,
                    SeminarPoints    = 20,
                    ProjectPoints    = 8,
                    AdditionalPoints = 3,
                    FinishDate       = DateTime.Parse("2019-6-11")
                },
                    new Enrollment
                {
                    CourseId         = 3,
                    StudentId        = 3,
                    Semester         = 6,
                    Year             = 3,
                    Grade            = 5,
                    SeminarUrl       = "https://",
                    ProjectUrl       = "https://",
                    ExamPoints       = 35,
                    SeminarPoints    = 25,
                    ProjectPoints    = 20,
                    AdditionalPoints = 10,
                    FinishDate       = DateTime.Parse("2020-2-3")
                },
                    new Enrollment
                {
                    CourseId         = 3,
                    StudentId        = 2,
                    Semester         = 7,
                    Year             = 4,
                    Grade            = 5,
                    SeminarUrl       = "https://",
                    ProjectUrl       = "https://",
                    ExamPoints       = 90,
                    SeminarPoints    = 25,
                    ProjectPoints    = 20,
                    AdditionalPoints = 10,
                    FinishDate       = DateTime.Parse("2013-8-11")
                },
                    new Enrollment
                {
                    CourseId         = 2,
                    StudentId        = 1,
                    Semester         = 4,
                    Year             = 2,
                    Grade            = 5,
                    SeminarUrl       = "https://",
                    ProjectUrl       = "https://",
                    ExamPoints       = 95,
                    SeminarPoints    = 25,
                    ProjectPoints    = 20,
                    AdditionalPoints = 10,
                    FinishDate       = DateTime.Parse("2017-5-11")
                },
                    new Enrollment
                {
                    CourseId         = 1,
                    StudentId        = 1,
                    Semester         = 8,
                    Year             = 4,
                    Grade            = 6,
                    SeminarUrl       = "https://",
                    ProjectUrl       = "https://",
                    ExamPoints       = 10,
                    SeminarPoints    = 30,
                    ProjectPoints    = 25,
                    AdditionalPoints = 15,
                    FinishDate       = DateTime.Parse("2015-6-11")
                }
                    );

                context.SaveChanges();
            }
        }