Exemplo n.º 1
0
 public static void Initializer(IServiceProvider serviceProvider)
 {
     using (var context = new RazorPageMovieContext(serviceProvider.GetRequiredService <DbContextOptions <RazorPageMovieContext> >()))
     {
         //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("1980-02-12"),
             Genre       = "Romantic",
             Price       = 7.99M,
             Rating      = "r"
         },
             new Movie
         {
             Title       = "John Wick",
             ReleaseDate = DateTime.Parse("2017-01-12"),
             Genre       = "Comedy Action Adventures",
             Price       = 12M,
             Rating      = "r"
         },
             new Movie
         {
             Title       = "John Wick-Chapter-2",
             ReleaseDate = DateTime.Parse("2018-02-12"),
             Price       = 30M,
             Rating      = "r"
         },
             new Movie
         {
             Title       = "John Wick-Chapter-3",
             ReleaseDate = DateTime.Parse("2019-09-09"),
             Price       = 60M,
             Rating      = "r"
         },
             new Movie
         {
             Title       = "Rio Bravo",
             ReleaseDate = DateTime.Parse("1959-2-23"),
             Price       = 8.99M,
             Rating      = "r"
         }
             );
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new RazorPageMovieContext(serviceProvider
                                                           .GetRequiredService <DbContextOptions <RazorPageMovieContext> >()))
            {
                //look for any movies
                if (context.Movies.Any())
                {
                    return; // DB has been seed
                }

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

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

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

                    new Movies
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M,
                    Rating      = "R"
                }
                    );
                context.SaveChanges();
            }
        }
Exemplo n.º 3
0
 public CreateModel(RazorPageMovie.Models.RazorPageMovieContext context)
 {
     _context = context;
 }
Exemplo n.º 4
0
 public DetailsModel(RazorPageMovie.Models.RazorPageMovieContext context)
 {
     _context = context;
 }
Exemplo n.º 5
0
 public IndexModel(RazorPageMovie.Models.RazorPageMovieContext context)
 {
     _context = context;
 }
Exemplo n.º 6
0
 public EditModel(RazorPageMovie.Models.RazorPageMovieContext context)
 {
     _context = context;
 }