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

                context.Book.AddRange(
                    new Book
                {
                    Title       = "Pollyannna",
                    PublishDate = DateTime.Parse("1979-5-10"),
                    Genre       = "Fiction",
                    Author      = "Eleanor Potter",
                    Rating      = "R"
                },

                    new Book
                {
                    Title       = "The Complete Reference ",
                    PublishDate = DateTime.Parse("2010-7-07"),
                    Genre       = "Education",
                    Author      = "Herbert Shildt",
                    Rating      = "R"
                }
                    );
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public IndexModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }
Ejemplo n.º 3
0
 public EditModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }
Ejemplo n.º 4
0
 public DeleteModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }
Ejemplo n.º 5
0
 public DetailsModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }
Ejemplo n.º 6
0
 public CreateModel(Bookshelf.Models.BookshelfContext context)
 {
     _context = context;
 }