Exemplo n.º 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new FinalContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <FinalContext> >()))
            {
                // Look for any Books.
                if (context.Book.Any())
                {
                    return;   // DB has been seeded
                }

                context.Book.AddRange(
                    new Book
                {
                    BookName   = "Operating Systems Internals and Design Principles 9th Edition by William Stallings",
                    CourseName = "Operating Systems",
                    CRN        = "CSC 350",
                    Major      = "CS",
                    ISBN       = 123456789,
                    Price      = 85.89M
                },



                    new Book
                {
                    BookName   = "Multivariable Calculus, 7th Edition by James Stewart",
                    CourseName = "Calculus 3",
                    CRN        = "Math 203",
                    Major      = "Math",
                    ISBN       = 123456789,
                    Price      = 7.99M
                }
                    );
                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new FinalContext(serviceProvider.GetRequiredService <DbContextOptions <FinalContext> >()))
            {
                CreateUserRoles(serviceProvider).Wait();

                if (context.Student.Any() || context.Teacher.Any() || context.Course.Any())
                {
                    return;
                }
                context.Teacher.AddRange(
                    new Teacher
                {
                    FirstName    = "Даниел",
                    LastName     = "Денковски",
                    Degree       = "Доктор на науки",
                    AcademicRank = "Доцент",
                    OfficeNumber = "121б",
                    HireDate     = DateTime.Parse("2017-1-01")
                },

                    new Teacher
                {
                    FirstName    = "Перо",
                    LastName     = "Латкоски",
                    Degree       = "Доктор на науки",
                    AcademicRank = "Ред. Професор",
                    OfficeNumber = "ТК",
                    HireDate     = DateTime.Parse("2006-1-01")
                },

                    new Teacher
                {
                    FirstName    = "Марија",
                    LastName     = "Календар",
                    Degree       = "Доктор на науки",
                    AcademicRank = "Ред. Професор",
                    OfficeNumber = "ФЛАОП",
                    HireDate     = DateTime.Parse("2006-1-01")
                },

                    new Teacher
                {
                    FirstName    = "Ана",
                    LastName     = "Чолакоска",
                    Degree       = "Магистер",
                    AcademicRank = "Асистент",
                    OfficeNumber = "121б",
                    HireDate     = DateTime.Parse("2017-1-01")
                }
                    );
                context.SaveChanges();

                context.Student.AddRange(
                    new Student
                {
                    StudentId       = "15/2017",
                    FirstName       = "Симона",
                    LastName        = "Малевска",
                    EnrollmentDate  = DateTime.Parse("2017-9-01"),
                    AcquiredCredits = 153,
                    CurrentSemester = 8,
                    EducationLevel  = "Додипломец",
                },

                    new Student
                {
                    StudentId       = "257/2017",
                    FirstName       = "Тијана",
                    LastName        = "Настевска",
                    EnrollmentDate  = DateTime.Parse("2017-9-01"),
                    AcquiredCredits = 147,
                    CurrentSemester = 8,
                    EducationLevel  = "Додипломец",
                }
                    );
                context.SaveChanges();

                context.Course.AddRange(
                    new Course
                {
                    Title           = "Развој на серверски WEB апликации",
                    Credits         = 6,
                    Semester        = 6,
                    Program         = "КТИ, ТКИИ",
                    EducationLevel  = "Додипломски",
                    FirstTeacherId  = context.Teacher.Single(t => t.FirstName == "Даниел" && t.LastName == "Денковски").Id,
                    SecondTeacherId = context.Teacher.Single(t => t.FirstName == "Перо" && t.LastName == "Латкоски").Id
                },

                    new Course
                {
                    Title           = "Микропроцесорски системи",
                    Credits         = 6,
                    Semester        = 6,
                    Program         = "КТИ",
                    EducationLevel  = "Додипломски",
                    FirstTeacherId  = context.Teacher.Single(t => t.FirstName == "Марија" && t.LastName == "Календар").Id,
                    SecondTeacherId = context.Teacher.Single(t => t.FirstName == "Ана" && t.LastName == "Чолакоска").Id
                }
                    );
                context.SaveChanges();

                context.Enrollment.AddRange(
                    new Enrollment
                {
                    CourseId         = context.Course.Single(t => t.Title == "Развој на серверски WEB апликации").Id,
                    StudentId        = context.Student.Single(t => t.FirstName == "Симона" && t.LastName == "Малевска").Id,
                    Semester         = "летен",
                    Year             = 2021,
                    Grade            = 0,
                    SeminalUrl       = " ",
                    ProjectUrl       = " ",
                    ExamPoints       = 0,
                    SeminalPoints    = 0,
                    ProjectPoints    = 0,
                    AdditionalPoints = 0,
                    FinishDate       = DateTime.Parse("2000-1-01"),
                },

                    new Enrollment
                {
                    CourseId         = context.Course.Single(t => t.Title == "Развој на серверски WEB апликации").Id,
                    StudentId        = context.Student.Single(t => t.FirstName == "Тијана" && t.LastName == "Настевска").Id,
                    Semester         = "летен",
                    Year             = 2021,
                    Grade            = 0,
                    SeminalUrl       = " ",
                    ProjectUrl       = " ",
                    ExamPoints       = 0,
                    SeminalPoints    = 0,
                    ProjectPoints    = 0,
                    AdditionalPoints = 0,
                    FinishDate       = DateTime.Parse("2000-1-01"),
                },

                    new Enrollment
                {
                    CourseId         = context.Course.Single(t => t.Title == "Микропроцесорски системи").Id,
                    StudentId        = context.Student.Single(t => t.FirstName == "Симона" && t.LastName == "Малевска").Id,
                    Semester         = "летен",
                    Year             = 2020,
                    Grade            = 7,
                    SeminalUrl       = " ",
                    ProjectUrl       = " ",
                    ExamPoints       = 67,
                    SeminalPoints    = 0,
                    ProjectPoints    = 0,
                    AdditionalPoints = 0,
                    FinishDate       = DateTime.Parse("2021-1-23"),
                }
                    );
                context.SaveChanges();
            }
        }