示例#1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MVCMovieContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MVCMovieContext> >()))
            {
                // 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
                },

                    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();
            }
        }
示例#2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MVCMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <MVCMovieContext> >()))
            {
                if (context.Movie.Any())
                {
                    return;
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry met Sally",
                    ReleaseDate = DateTime.Parse("1989-01-01"),
                    Genre       = "Romantic Comedy",
                    Rating      = "R",
                    Price       = 7
                },
                    new Movie
                {
                    Title       = "Ghostbusters",
                    ReleaseDate = DateTime.Parse("1994-01-01"),
                    Genre       = "Comedy",
                    Rating      = "R",
                    Price       = 10
                },
                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1996-01-01"),
                    Genre       = " Comedy",
                    Rating      = "R",
                    Price       = 12
                },
                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1999-01-01"),
                    Genre       = "Western",
                    Rating      = "R",
                    Price       = 6
                }
                    );
                context.SaveChanges();
            }
        }
示例#3
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MVCMovieContext(
                       serviceProvider.GetRequiredService <DbContextOptions <MVCMovieContext> >()))
            {
                // Look for any movies.
                if (context.Accounts.Any())
                {
                    return;                       // DB has been seeded
                }

                context.Accounts.AddRange(
                    new Accounts
                {
                    Enabled     = false,
                    Name        = "Account One",
                    PhoneNumber = "111-111-1111"
                },

                    new Accounts
                {
                    Enabled     = true,
                    Name        = "Account True",
                    PhoneNumber = "222-222-2222"
                },

                    new Accounts
                {
                    Enabled     = false,
                    Name        = "Account Three",
                    PhoneNumber = "333-333-3333"
                },

                    new Accounts
                {
                    Enabled     = true,
                    Name        = "Account Four",
                    PhoneNumber = "444-444-4444"
                }
                    );
                context.SaveChanges();
            }
        }
示例#4
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new MVCMovieContext(serviceProvider.GetRequiredService <DbContextOptions <MVCMovieContext> >()))
     {
         if (context.Movie.Any())
         {
             return;
         }
         context.Movie.AddRange(new Movie {
             Title = "Johhny Bravo", ReleaseDate = DateTime.Parse("1995-05-05"), Genre = "Cartoon", Price = 7.99M, Rating = "R"
         },
                                new Movie {
             Title = "Johhny Alpha", ReleaseDate = DateTime.Parse("1991-05-05"), Genre = "Cartoon", Price = 9.99M, Rating = "R"
         },
                                new Movie {
             Title = "Johhny Charlie", ReleaseDate = DateTime.Parse("1992-05-05"), Genre = "Cartoon", Price = 10.99M, Rating = "R"
         });
         context.SaveChanges();
     }
 }
示例#5
0
 public MoviesController(MVCMovieContext context)
 {
     _context = context;
 }
示例#6
0
 public GenrController(MVCMovieContext context)
 {
     _context = context;
 }
示例#7
0
 public MoviesController(MVCMovieContext context, ILogger <MoviesController> logger)
 {
     _context = context;
     _logger  = logger;
 }
 public MovieRepository(MVCMovieContext context)
 {
     _context = context;
 }