public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >())) {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                #region snippet1
                context.Movie.AddRange(
                    new Movie {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M,
                    Rating      = "R"
                },
                    #endregion

                    new Movie {
                    Title       = "Ghostbusters ",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = 8.99M,
                    Rating      = "G"
                },

                    new Movie {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "G"
                },

                    new Movie {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M,
                    Rating      = "NA"
                }
                    );
                context.SaveChanges();
            }
        }
예제 #2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()))
            {
                //Look for any movies.
                if (context.Movie.Any())
                {
                    return; //db has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "Rush Hour",
                    ReleaseDate = DateTime.Parse("1998-9-18"),
                    Genre       = "Action",
                    Price       = 7.99M,
                    Rating      = "R"
                },
                    new Movie
                {
                    Title       = "Frozen",
                    ReleaseDate = DateTime.Parse("2013-11-27"),
                    Genre       = "Fantasy",
                    Price       = 9.99M,
                    Rating      = "PG"
                },
                    new Movie
                {
                    Title       = "Ad Astra",
                    ReleaseDate = DateTime.Parse("2019-9-18"),
                    Genre       = "Drama",
                    Price       = 14.99M,
                    Rating      = "R"
                },
                    new Movie
                {
                    Title       = "A Quiet Place",
                    ReleaseDate = DateTime.Parse("2018-4-6"),
                    Genre       = "Drama",
                    Price       = 12.99M,
                    Rating      = "R"
                }
                    );
                context.SaveChanges();
            }
        }
예제 #3
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                //DBにムービーがある場合、シード初期化子が返され、ムービーは追加されない
                if (context.Movie.Any())
                {
                    return; //DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M
                },

                    new Movie
                {
                    Title       = "Ghostbusters",
                    ReleaseDate = DateTime.Parse("1934-5-1"),
                    Genre       = "Comedy",
                    Price       = 8.99M
                },

                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1936-6-3"),
                    Genre       = "Comedy",
                    Price       = 9.99M
                },

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-23"),
                    Genre       = "Western",
                    Price       = 3.99M
                }
                    );
                context.SaveChanges();
            }
        }
예제 #4
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                if (context.Movie.Any())
                {
                    return;
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = "7.99M"
                },

                    new Movie
                {
                    Title       = "Ghostbusters ",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = "8.99M"
                },

                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = "9.99M"
                },

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = "3.99M"
                }
                    );

                context.SaveChanges();
            }
        }
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new RazorPagesMovieContext(
                serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()))
     {
         //Look for any movies.
         if (context.Movies.Any())
         {
             return;
         }
         context.Movies.AddRange(
             new Movie
         {
             Title       = "When Harry Met Sally",
             ReleaseDate = DateTime.Parse("1988-2-12"),
             Genre       = "Romantic",
             Price       = 7.99M,
             Rating      = "R"
         },
             new Movie
         {
             Title       = "When Met Sally",
             ReleaseDate = DateTime.Parse("1918-2-12"),
             Genre       = "Horror",
             Price       = 78.1M,
             Rating      = "L"
         },
             new Movie
         {
             Title       = "Wet Sally",
             ReleaseDate = DateTime.Parse("1998-2-12"),
             Genre       = "Gospel",
             Price       = 15.99M,
             Rating      = "B"
         },
             new Movie
         {
             Title       = "Met Sally",
             ReleaseDate = DateTime.Parse("1000-2-12"),
             Genre       = "Suspense",
             Price       = 7.99M,
             Rating      = "A"
         }
             );
         context.SaveChanges();
     }
 }
예제 #6
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()))
            {
                // look for any movies
                if (!context.Movie.Any())
                {
                    context.Movie.AddRange(
                        new Movie
                    {
                        Title       = "When Harry Met Sally",
                        ReleaseDate = DateTime.Parse("12/2/1989"),
                        Genre       = "Romantic Comedy",
                        Price       = 7.99M,
                        Rating      = "R"
                    },
                        new Movie
                    {
                        Title       = "Ghostbusters",
                        ReleaseDate = DateTime.Parse("13/3/1984"),
                        Genre       = "Comedy",
                        Price       = 8.99M,
                        Rating      = "R"
                    },
                        new Movie
                    {
                        Title       = "Ghostbusters 2",
                        ReleaseDate = DateTime.Parse("23/2/1986"),
                        Genre       = "Comedy",
                        Price       = 9.99M,
                        Rating      = "R"
                    },
                        new Movie
                    {
                        Title       = "Rio Bravo",
                        ReleaseDate = DateTime.Parse("15/4/1954"),
                        Genre       = "Western",
                        Price       = 3.99M,
                        Rating      = "R"
                    }
                        );

                    context.SaveChanges();
                }
            }
        }
예제 #7
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()))
            {
                //Look for any movies
                if (context.Movie.Any())
                {
                    return; //DB has been seeded
                }

                context.Movie.AddRange(new Movie
                {
                    Title       = "Back to the Future",
                    ReleaseDate = DateTime.Parse("1985-12-4"),
                    Genre       = "Science fiction",
                    Price       = 7.99M
                },

                                       new Movie
                {
                    Title       = "Ghostbusters",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = 8.99M
                },

                                       new Movie
                {
                    Title       = "Back to the Future Part II",
                    ReleaseDate = DateTime.Parse("1989-11-24"),
                    Genre       = "Science fiction",
                    Price       = 4.99M
                },

                                       new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M
                }
                                       );
                context.SaveChanges();
            }
        }
예제 #8
0
파일: SeedData.cs 프로젝트: Romu1us1408/C-
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(

                    );
                context.SaveChanges();
            }
        }
예제 #9
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                // looking for any movies
                if (context.Movie.Any())
                {
                    return; //DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "How I meet your mother",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "R"
                },

                    new Movie
                {
                    Title       = "Harry Potter and The Half-Prince",
                    ReleaseDate = DateTime.Parse("2007-2-12"),
                    Genre       = "Adventure",
                    Price       = 7.99M,
                    Rating      = "R"
                },

                    new Movie
                {
                    Title       = "Black Widow",
                    ReleaseDate = DateTime.Parse("2021-4-21"),
                    Genre       = "Action",
                    Price       = 8.99M,
                    Rating      = "R"
                }
                    );
                context.SaveChanges();
            }
        }
예제 #10
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (RazorPagesMovieContext context = new RazorPagesMovieContext(
                serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()
                ))
     {
         if (context.Movie.Any())
         {
             return;
         }
         context.Movie.AddRange(
             new Movie
         {
             Title   = "When Harry Met Sally",
             Release = DateTime.Parse("1989-2-12"),
             Price   = 7.99f,
             Rating  = "R"
         },
             new Movie
         {
             Title   = "Ghostbusters",
             Release = DateTime.Parse("1984-3-13"),
             Price   = 8.99f,
             Rating  = "PG"
         },
             new Movie
         {
             Title   = "Ghostbusters 2",
             Release = DateTime.Parse("1986-2-23"),
             Price   = 9.99f,
             Rating  = "PG"
         },
             new Movie
         {
             Title   = "Rio Bravo",
             Release = DateTime.Parse("1959-4-15"),
             Price   = 3.99f,
             Rating  = "U"
         }
             );
         context.SaveChanges();
     }
 }
예제 #11
0
        public static void Initialize (IServiceProvider serviceProvider){
            using (var context = new RazorPagesMovieContext(
                serviceProvider.GetRequiredService<DbContextOptions<RazorPagesMovieContext>>())) {
                
                // Does any movies exist in database ?
                if (context.Movie.Any())
                {
                    // Database has already been seeded.
                    return;
                }

                // Movies does not exist in database.
                context.Movie.AddRange(
                    new Movie {
                        Title = "Superman III",
                        ReleaseDate = DateTime.Parse("1989-5-17"),
                        Genre = "SciFi / Fantasy",
                        Price = 6.99M,
                        Rating = "G"
                    },

                    new Movie
                    {
                        Title = "Ghostbusters 2",
                        ReleaseDate = DateTime.Parse("1986-2-23"),
                        Genre = "Comedy",
                        Price = 9.99M,
                        Rating = "PG"
                    },

                    new Movie
                    {
                        Title = "Rio Bravo",
                        ReleaseDate = DateTime.Parse("1959-4-15"),
                        Genre = "Western",
                        Price = 3.99M,
                        Rating = "R"
                    }
                );
                context.SaveChanges();
            }
        }
예제 #12
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new RazorPagesMovieContext(
                serviceProvider.GetRequiredService <
                    DbContextOptions <RazorPagesMovieContext> >()))
     {
         // Look for any movies
         if (context.Movie.Any())
         {
             // DB has been seeded
             return;
         }
         context.Movie.AddRange(
             new Movie
         {
             Title       = "Drunken Master",
             ReleaseDate = DateTime.Parse("1990-2-23"),
             Genre       = "Action",
             Price       = 1.2M,
             Rating      = "R"
         },
             new Movie
         {
             Title       = "Me and Rebekah",
             ReleaseDate = DateTime.Parse("1991-3-18"),
             Genre       = "Romance",
             Price       = 30M,
             Rating      = "PG"
         },
             new Movie
         {
             Title       = "Chamber of Secrets",
             ReleaseDate = DateTime.Parse("2008-4-17"),
             Genre       = "Magical Series",
             Price       = 80000,
             Rating      = "XXX"
         }
             );
         context.SaveChanges();
     }
 }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.
                // If there any movies in the DB.
                if (context.Movie.Any())
                {
                    return; // DB has been seeded.
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M
                },

                    new Movie
                {
                    Title       = "Gostbusters ",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M
                },

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M
                }
                    );
                context.SaveChanges();
            }
        }
예제 #14
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Categoria = "Ingles",
                    Pacote    = "Bimestre 01",
                },

                    new Movie
                {
                    Categoria = "Matematica",
                    Pacote    = "Bimestre 01",
                },

                    new Movie
                {
                    Categoria = "Portugues",
                    Pacote    = "Bimestre 01",
                },

                    new Movie
                {
                    Categoria = "Geografia",
                    Pacote    = "Bimestre 01",
                }
                    );
                context.SaveChanges();
            }
        }
예제 #15
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                if (context.Movie.Any())
                {
                    return;
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "hello",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "hello",
                    Price       = 7.99M
                },

                    new Movie
                {
                    Title       = "hello",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "hello",
                    Price       = 7.99M
                },

                    new Movie
                {
                    Title       = "hello",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "hello",
                    Price       = 7.99M
                }
                    );
                context.SaveChanges();
            }
        }
예제 #16
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()))
            {
                //Look for any Movies:
                if (context.Movie.Any())
                {
                    return; // DB has been seeded.
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M
                }
                    );
                context.SaveChanges();
            }
        }
예제 #17
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Book        = "2 Nephi 33:12",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Scripture   = " And I pray the Father in the name of Christ that many of us, if not all, may be saved in his kingdom at that great and last day",
                }


                    );
                context.SaveChanges();
            }
        }
예제 #18
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            var dbContextOptions = serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >();

            using (var context = new RazorPagesMovieContext(dbContextOptions))
            {
                // Movie table already populated
                if (context.Movie.Any())
                {
                    return;
                }

                // TODO: Parse from CSV, web-scrape from IMDB/RottenTomatoes?

                context.Movie.AddRange(
                    new Movie("When Harry Met Sally", "1989-2-12", "Romantic Comedy", 7.99M),
                    new Movie("Ghostbusters", "1984-3-13", "Comedy", 8.99M),
                    new Movie("Ghostbusters 2", "1986-2-23", "Comedy", 9.99M),
                    new Movie("Rio Bravo", "1959-4-15", "Western", 3.99M)
                    );

                context.SaveChanges();
            }
        }
예제 #19
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any() && context.Customer.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M,
                    Rating      = "R",
                    Director    = "Unknown"
                },

                    new Movie
                {
                    Title       = "Ghostbusters ",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = 8.99M,
                    Rating      = "R",
                    Director    = "Ivan Reitman"
                },

                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "R",
                    Director    = "Unknown"
                },

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M,
                    Rating      = "R",
                    Director    = "Unknown"
                }
                    );

                context.Customer.AddRange(
                    new Customer
                {
                    EmailAddress = "*****@*****.**",
                    Salutation   = Title.Mr,
                    Name         = "Arnoldo",
                    Lastname     = "Perozo",
                    BirthDate    = DateTime.Parse("1977-3-05"),
                    Gender       = 0,
                    Address      = "Heredia",
                    Phone        = "123-4567890"
                },

                    new Customer
                {
                    EmailAddress = "*****@*****.**",
                    Salutation   = Title.Mrs,
                    Name         = "Rita",
                    Lastname     = "Moreno",
                    BirthDate    = DateTime.Parse("1989-10-10"),
                    Gender       = Gender.Female,
                    Address      = "Not Sure",
                    Phone        = "123-4567890"
                },

                    new Customer
                {
                    EmailAddress = "*****@*****.**",
                    Salutation   = Title.Miss,
                    Name         = "Johanna",
                    Lastname     = "Sanchez",
                    BirthDate    = DateTime.Parse("1995-8-18"),
                    Gender       = Gender.Female,
                    Address      = "Don't Know",
                    Phone        = "123-4567890"
                });

                context.SaveChanges();
            }
        }
예제 #20
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M,
                    Rating      = "R"
                },

                    new Movie
                {
                    Title       = "Ghostbusters ",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = 8.99M,
                    Rating      = "PG-13"
                },

                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "PG-13"
                },

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M,
                    Rating      = "R"
                }
                    );

                if (context.Review.Any())
                {
                    return;   // DB has been seeded
                }

                Review review1 = new Review {
                    Score = 1
                };
                Review review2 = new Review {
                    Score = 2
                };
                Review review3 = new Review {
                    Score = 3
                };
                Review review4 = new Review {
                    Score = 4
                };
                Review review5 = new Review {
                    Score = 5
                };

                context.Add(review1);
                context.Add(review2);
                context.Add(review3);
                context.Add(review4);
                context.Add(review5);


                context.SaveChanges();
            }
        }
예제 #21
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()))
            {
                //Look for any movie
                if (context.Movie.Any())
                {
                    return;
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M,
                    Rating      = "A"
                },
                    new Movie
                {
                    Title       = "Ghostbusters ",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = 8.99M,
                    Rating      = "B"
                },
                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "A"
                },
                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M,
                    Rating      = "C"
                },
                    new Movie
                {
                    Title       = "London's Query",
                    ReleaseDate = DateTime.Parse("1999-4-15"),
                    Genre       = "Tragedy",
                    Price       = 4.00M,
                    Rating      = "A"
                },
                    new Movie
                {
                    Title       = "Dance of the Leaf",
                    ReleaseDate = DateTime.Parse("2012-12-01"),
                    Genre       = "Thriller",
                    Price       = 1.99M,
                    Rating      = "F"
                },
                    new Movie
                {
                    Title       = "Jonhney Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Comedy",
                    Price       = 1.90M,
                    Rating      = "B"
                }
                    );
                context.SaveChanges();
            }
        }
예제 #22
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                //look for any movies.
                if (context.Movie.Any())
                {
                    return; //DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "Spider Man ",
                    ReleaseDate = DateTime.Parse("2015-3-11"),
                    Genre       = "Superhero",
                    Price       = 88M,
                    Rating      = "G"
                },

                    new Movie
                {
                    Title       = "Inception ",
                    ReleaseDate = DateTime.Parse("2018-1-11"),
                    Genre       = "Sci-Fic",
                    Price       = 99M,
                    Rating      = "PG-13"
                },

                    new Movie
                {
                    Title       = "The Wadering Earth ",
                    ReleaseDate = DateTime.Parse("01/13/2019"),
                    Genre       = "Sci-Fic",
                    Price       = 110M,
                    Rating      = "G"
                },

                    new Movie
                {
                    Title       = "Iron Man",
                    ReleaseDate = DateTime.Parse("12/12/2015"),
                    Genre       = "Superhero",
                    Price       = 30M,
                    Rating      = "G"
                },

                    new Movie
                {
                    Title       = "DealPool",
                    ReleaseDate = DateTime.Parse("1/4/2017"),
                    Genre       = "Superhero",
                    Price       = 55M,
                    Rating      = "R"
                }
                    );
                context.SaveChanges();
            }
        }
예제 #23
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.

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

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

                var courses = new Course[]
                {
                    new Course {
                        CourseID = 1050, Title = "Chemistry", Credits = 3
                    },
                    new Course {
                        CourseID = 4022, Title = "Microeconomics", Credits = 3
                    },
                    new Course {
                        CourseID = 4041, Title = "Macroeconomics", Credits = 3
                    },
                    new Course {
                        CourseID = 1045, Title = "Calculus", Credits = 4
                    },
                    new Course {
                        CourseID = 3141, Title = "Trigonometry", Credits = 4
                    },
                    new Course {
                        CourseID = 2021, Title = "Composition", Credits = 3
                    },
                    new Course {
                        CourseID = 2042, Title = "Literature", Credits = 4
                    }
                };
                foreach (Course c in courses)
                {
                    context.Courses.Add(c);
                }
                context.SaveChanges();

                var enrollments = new Enrollment[]
                {
                    new Enrollment {
                        StudentID = 1, CourseID = 1050, Grade = Grade.A
                    },
                    new Enrollment {
                        StudentID = 1, CourseID = 4022, Grade = Grade.C
                    },
                    new Enrollment {
                        StudentID = 1, CourseID = 4041, Grade = Grade.B
                    },
                    new Enrollment {
                        StudentID = 2, CourseID = 1045, Grade = Grade.B
                    },
                    new Enrollment {
                        StudentID = 2, CourseID = 3141, Grade = Grade.F
                    },
                    new Enrollment {
                        StudentID = 2, CourseID = 2021, Grade = Grade.F
                    },
                    new Enrollment {
                        StudentID = 3, CourseID = 1050
                    },
                    new Enrollment {
                        StudentID = 4, CourseID = 1050
                    },
                    new Enrollment {
                        StudentID = 4, CourseID = 4022, Grade = Grade.F
                    },
                    new Enrollment {
                        StudentID = 5, CourseID = 4041, Grade = Grade.C
                    },
                    new Enrollment {
                        StudentID = 6, CourseID = 1045
                    },
                    new Enrollment {
                        StudentID = 7, CourseID = 3141, Grade = Grade.A
                    },
                };
                foreach (Enrollment e in enrollments)
                {
                    context.Enrollments.Add(e);
                }
                context.SaveChanges();

                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }
                for (var i = 0; i < 5; i++)
                {
                    context.Movie.AddRange(
                        new Movie
                    {
                        Title       = "When Harry Met Sally",
                        ReleaseDate = DateTime.Parse("1989-2-12"),
                        Genre       = "Romantic Comedy",
                        Price       = 7.99M,
                        Rating      = "R"
                    },

                        new Movie
                    {
                        Title       = "Ghostbusters ",
                        ReleaseDate = DateTime.Parse("1984-3-13"),
                        Genre       = "Comedy",
                        Price       = 8.99M,
                        Rating      = "R"
                    },

                        new Movie
                    {
                        Title       = "Ghostbusters 2",
                        ReleaseDate = DateTime.Parse("1986-2-23"),
                        Genre       = "Comedy",
                        Price       = 9.99M,
                        Rating      = "R"
                    },

                        new Movie
                    {
                        Title       = "Rio Bravo",
                        ReleaseDate = DateTime.Parse("1959-4-15"),
                        Genre       = "Western",
                        Price       = 3.99M,
                        Rating      = "R"
                    }
                        );
                }

                context.SaveChanges();
            }
        }
예제 #24
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M,
                    Rating      = "R"
                },

                    new Movie
                {
                    Title       = "Ghostbusters ",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = 8.99M,
                    Rating      = "PG"
                },

                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "PG"
                },

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M,
                    Rating      = "NA"
                }
                    );

                if (context.Actor.Any())
                {
                    return;   // DB has been seeded
                }

                context.Actor.AddRange(
                    new Actor
                {
                    ActorId   = "BM459632",
                    LastName  = "Murray",
                    FirstName = "Bill",
                    BirthDate = DateTime.Parse("1950-9-21")
                },

                    new Actor
                {
                    ActorId   = "DA632894",
                    LastName  = "Aykroyd",
                    FirstName = "Dan",
                    BirthDate = DateTime.Parse("1952-7-01")
                },

                    new Actor
                {
                    ActorId   = "BC821145",
                    LastName  = "Crystal",
                    FirstName = "Billy",
                    BirthDate = DateTime.Parse("1948-3-14")
                },

                    new Actor
                {
                    ActorId   = "JW358564",
                    LastName  = "Wayne",
                    FirstName = "John",
                    BirthDate = DateTime.Parse("1907-5-26")
                }
                    );
                context.SaveChanges();
            }
        }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title          = "When Harry Met Sally",
                    ReleaseDate    = DateTime.Parse("1989-2-12"),
                    Genre          = "Romantic Comedy",
                    Price          = 7.99M,
                    Rating         = "R",
                    BoxOfficeSales = 92800000M,
                    MyRating       = 9,
                    Distribution   = "US"
                },

                    new Movie
                {
                    Title          = "Ghostbusters ",
                    ReleaseDate    = DateTime.Parse("1984-3-13"),
                    Genre          = "Comedy",
                    Price          = 8.99M,
                    Rating         = "PG",
                    BoxOfficeSales = 229100000M,
                    MyRating       = 7,
                    Distribution   = "US"
                },

                    new Movie
                {
                    Title          = "Ghostbusters 2",
                    ReleaseDate    = DateTime.Parse("1986-2-23"),
                    Genre          = "Comedy",
                    Price          = 9.99M,
                    Rating         = "PG",
                    BoxOfficeSales = 215400000M,
                    MyRating       = 6,
                    Distribution   = "US"
                },

                    new Movie
                {
                    Title          = "Rio Bravo",
                    ReleaseDate    = DateTime.Parse("1959-4-15"),
                    Genre          = "Western",
                    Price          = 3.99M,
                    Rating         = "PG13",
                    BoxOfficeSales = 5750000M,
                    MyRating       = 10,
                    Distribution   = "US"
                }
                    );
                context.SaveChanges();
            }
        }
예제 #26
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            bool mustSaveChanges = false;

            using RazorPagesMovieContext context = new RazorPagesMovieContext(
                      serviceProvider.GetRequiredService <
                          DbContextOptions <RazorPagesMovieContext> >());

            if (context.Movie.Count(_ => _.Title.Equals("When Harry Met Sally")) == 0)
            {
                context.Movie.Add(new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M,
                    Rating      = "R"
                });
                mustSaveChanges = true;
            }

            if (context.Movie.Count(_ => _.Title.Equals("Ghostbusters")) == 0)
            {
                context.Movie.Add(new Movie
                {
                    Title       = "Ghostbusters",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = 8.99M,
                    Rating      = "G"
                });
                mustSaveChanges = true;
            }

            if (context.Movie.Count(_ => _.Title.Equals("Ghostbusters 2")) == 0)
            {
                context.Movie.Add(new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "G"
                });
                mustSaveChanges = true;
            }

            if (context.Movie.Count(_ => _.Title.Equals("Rio Bravo")) == 0)
            {
                context.Movie.Add(new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M,
                    Rating      = "NA"
                });
                mustSaveChanges = true;
            }

            if (mustSaveChanges)
            {
                context.SaveChanges();
            }

            List <Movie> notRatedMovies = context.Movie.Where(_ => string.IsNullOrEmpty(_.Rating)).ToList();

            if (notRatedMovies.Count > 0)
            {
                notRatedMovies.ForEach(_ => _.Rating = "NA");
                context.SaveChanges();
            }
        }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPagesMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <RazorPagesMovieContext> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M,
                    Rating      = "R"
                },

                    new Movie
                {
                    Title       = "Ghostbusters",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = 8.99M,
                    Rating      = "G"
                },

                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "G"
                },

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M,
                    Rating      = "NA"
                }
                    );

                Review Score1 = new Review
                {
                    Score = 1
                };
                context.Add(Score1);

                Review Score2 = new Review
                {
                    Score = 2
                };
                context.Add(Score2);

                Review Score3 = new Review
                {
                    Score = 3
                };
                context.Add(Score3);

                Review Score4 = new Review
                {
                    Score = 4
                };
                context.Add(Score4);

                Review Score5 = new Review
                {
                    Score = 5
                };
                context.Add(Score5);

                Movie addReviewHarrySally = context.Movie.Where(m => m.Title == "When Harry Met Sally").First();
                addReviewHarrySally.Reviews.Add(Score4);

                Movie addReviewGhost = context.Movie.Where(m => m.Title == "Ghostbusters").First();
                addReviewGhost.Reviews.Add(Score3);
                addReviewGhost.Reviews.Add(Score2);

                Movie addReviewRio = context.Movie.Where(m => m.Title == "Rio Bravo").First();
                addReviewRio.Reviews.Add(Score5);
                addReviewRio.Reviews.Add(Score5);
                addReviewRio.Reviews.Add(Score4);

                context.SaveChanges();
            }
        }