internal static void SeedIfnotEmpty(BookService.Models.BookServiceContext context) { context.Authors.AddOrUpdate(x => x.Id, new Author() { Id = 1, Name = "Jane Austen" }, new Author() { Id = 2, Name = "Charles Dickens" }, new Author() { Id = 3, Name = "Miguel De Cervantes" } ); context.Books.AddOrUpdate(x => x.Id, new Book() { Id = 1, Title = "Pride and Prejudice", Year = 1813, AuthorId = 1, Price = 9.99M, Genre = "Comedy of Manners" }, new Book() { Id = 2, Title = "Northanger Abbey", Year = 1817, AuthorId = 1, Price = 12.95M, Genre = "Gothic Parody" }, new Book() { Id = 3, Title = "David Copperfield", Year = 1850, AuthorId = 2, Price = 2, Genre = "Bildungroman" }, new Book() { Id = 4, Title = "Don Quixote", Year = 1617, AuthorId = 3, Price = 8.95M, Genre = "Picarsque" } ); context.SaveChanges(); }
public AuthorsController(BookServiceContext context) { _context = context; }
public BooksController(BookServiceContext context) { _context = context; }