Exemplo n.º 1
0
        public static void EnsurePopulated(IApplicationBuilder application)
        {
            MovieDBContext context = application.ApplicationServices.
                                     CreateScope().ServiceProvider.GetRequiredService <MovieDBContext>();

            if (context.Database.GetPendingMigrations().Any())
            {
                context.Database.Migrate();
            }

            if (!context.Movies.Any())
            {
                context.Movies.AddRange(
                    new Movie
                {
                    Title    = "Tenet",
                    Category = "Action/Adventure",
                    Year     = 2020,
                    Director = "Christopher Nolan",
                    Rating   = "G",
                    Edited   = "n/a",
                    Notes    = "n/a",
                    Lent     = "n/a"
                }
                    );
                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
 public void AddMovie(Movie movie)
 {
     _context.Movies.Add(movie);
     _context.SaveChanges();
 }