public EFOrderRepository(BookstoreDbContext ctx) { context = ctx; }
public static void EnsurePopulated(IApplicationBuilder application) { BookstoreDbContext context = application.ApplicationServices.CreateScope().ServiceProvider.GetRequiredService <BookstoreDbContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.Books.Any()) { context.Books.AddRange( //Pre-load books to DB new Book { Title = "Les Miserables", AuthorFirst = "Victor", AuthorLast = "Hugo", Publisher = "Signet", ISBN = "978-0451419439", Category = "Fiction", Genre = "Classic", Price = 9.95F, Pages = 1488 }, new Book { Title = "Team of Rivals", AuthorFirst = "Doris Kearns", AuthorLast = "Goodwin", Publisher = "Simon & Schuster", ISBN = "978-0743270755", Category = "Non-Fiction", Genre = "Biography", Price = 14.58F, Pages = 944 }, new Book { Title = "The Snowball", AuthorFirst = "Alice", AuthorLast = "Schroeder", Publisher = "Bantam", ISBN = "978-0553384611", Category = "Non-Fiction", Genre = "Biography", Price = 21.54F, Pages = 832 }, new Book { Title = "Deep Work", AuthorFirst = "Cal", AuthorLast = "Newport", Publisher = "Grand Central Publishing", ISBN = "978-1455586691", Category = "Non-Fiction", Genre = "Self-Help", Price = 14.99F, Pages = 304 }, new Book { Title = "Unbroken", AuthorFirst = "Laura", AuthorLast = "Hillenbrand", Publisher = "Random House", ISBN = "978-0812974492", Category = "Non-Fiction", Genre = "Historical", Price = 13.33F, Pages = 528 }, new Book { Title = "American Ulysses", AuthorFirst = "Ronald", AuthorLast = "White", Publisher = "Random House", ISBN = "978-0812981254", Category = "Non-Fiction", Genre = "Biography", Price = 11.61F, Pages = 864 }, new Book { Title = "The Great Train Robbery", AuthorFirst = "Michael", AuthorLast = "Crichton", Publisher = "Vintage", ISBN = "978-0804171281", Category = "Fiction", Genre = "Historical Fiction", Price = 15.95F, Pages = 288 }, new Book { Title = "It's Your Ship", AuthorFirst = "Michael", AuthorLast = "Abrashoff", Publisher = "Grand Central Publishing", ISBN = "978-1455523023", Category = "Non-Fiction", Genre = "Self-Help", Price = 21.66F, Pages = 240 }, new Book { Title = "The Virgin Way", AuthorFirst = "Richard", AuthorLast = "Branson", Publisher = "Portfolio", ISBN = "978-1591847984", Category = "Non-Fiction", Genre = "Business", Price = 29.16F, Pages = 400 }, new Book { Title = "Sycamore Row", AuthorFirst = "John", AuthorLast = "Grisham", Publisher = "Bantam", ISBN = "978-0553393613", Category = "Fiction", Genre = "Thrillers", Price = 15.03F, Pages = 642 }, new Book { Title = "Hatchet", AuthorFirst = "Gary", AuthorLast = "Paulsen", Publisher = "Simon & Schuster", ISBN = "9781416925088", Category = "Fiction", Genre = "Adventure", Price = 15.88F, Pages = 198 }, new Book { Title = "The Book of Mormon", AuthorFirst = "Mormon", AuthorLast = "", Publisher = "Harmony", ISBN = "9780385513166", Category = "Gospel", Genre = "Religious", Price = 17.90F, Pages = 531 }, new Book { Title = "The Giver", AuthorFirst = "Lois", AuthorLast = "Lowry", Publisher = "Houghton Mifflin Harcourt", ISBN = "9780547424774", Category = "Fiction", Genre = "SciFi", Price = 39.13F, Pages = 222 } ); context.SaveChanges(); } }
public static void EnsurePopulated(IApplicationBuilder application) { BookstoreDbContext context = application.ApplicationServices. CreateScope().ServiceProvider.GetRequiredService <BookstoreDbContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.Books.Any()) { context.Books.AddRange( new Book { Title = "Les Miserables", AuthorFirst = "Victor", AuthorMiddle = "", AuthorLast = "Hugo", Publisher = "Signet", ISBN = "978-0451419439", Classification = "Fiction", Category = "Classic", Price = 9.95, Page = 1488 }, new Book { Title = "Team of Rivals", AuthorFirst = "Doris", AuthorMiddle = "Kearns", AuthorLast = "Goodwin", Publisher = "Simon & Schuster", ISBN = "978-0743270755", Classification = "Non-Fiction", Category = "Biography", Price = 14.58, Page = 944 }, new Book { Title = "The Snowball", AuthorFirst = "Alice", AuthorMiddle = "", AuthorLast = "Schroeder", Publisher = "Random House", ISBN = "978-0553384611", Classification = "Non-Fiction", Category = "Biography", Price = 21.54, Page = 832 }, new Book { Title = "American Ulysses", AuthorFirst = "Ronald", AuthorMiddle = "C.", AuthorLast = "White", Publisher = "Random House", ISBN = "978-0812981254", Classification = "Non-Fiction", Category = "Biography", Price = 11.61, Page = 864 }, new Book { Title = "Unbroken", AuthorFirst = "Laura", AuthorMiddle = "", AuthorLast = "Hillenbrad", Publisher = "Random House", ISBN = "978-0812974492", Classification = "Non-Fiction", Category = "Historical", Price = 13.33, Page = 528 }, new Book { Title = "The Great Train Robbery", AuthorFirst = "Michael", AuthorMiddle = "", AuthorLast = "Crichton", Publisher = "Vintage", ISBN = "978-0804171281", Classification = "Fiction", Category = "Historical Fiction", Price = 15.95, Page = 288 }, new Book { Title = "Deep Work", AuthorFirst = "Cal", AuthorMiddle = "", AuthorLast = "Newport", Publisher = "Grand Central Publishing", ISBN = "978-1455586691", Classification = "Non-Fiction", Category = "Self-Help", Price = 14.99, Page = 304 }, new Book { Title = "It's Your Ship", AuthorFirst = "Michael", AuthorMiddle = "", AuthorLast = "Abrashoff", Publisher = "Grand Central Publishing", ISBN = "978-1455523023", Classification = "Non-Fiction", Category = "Self-Help", Price = 21.66, Page = 240 }, new Book { Title = "The Virgin Way", AuthorFirst = "Richard", AuthorMiddle = "", AuthorLast = "Branson", Publisher = "Portfolio", ISBN = "978-1591847984", Classification = "Non-Fiction", Category = "Business", Price = 29.16, Page = 400 }, new Book { Title = "Sycamore Row", AuthorFirst = "John", AuthorMiddle = "", AuthorLast = "Grisham", Publisher = "Bantam", ISBN = "978-0553393613", Classification = "Fiction", Category = "Thrillers", Price = 21.66, Page = 642 }, new Book { Title = "The Great Gatsby", AuthorFirst = "F.", AuthorMiddle = "Scott", AuthorLast = "Fitzgerald", Publisher = "Simon & Schuster", ISBN = "978-9915861036", Classification = "Fiction", Category = "Classic", Price = 8.74, Page = 189 }, new Book { Title = "See, I Told You So", AuthorFirst = "Rush", AuthorMiddle = "", AuthorLast = "Limbaugh", Publisher = "Pocket", ISBN = "978-0671871215", Classification = "Fiction", Category = "Political", Price = 25.99, Page = 448 }, new Book { Title = "The 7 Habits of Highly Effective People", AuthorFirst = "Steven", AuthorMiddle = "R.", AuthorLast = "Covey", Publisher = "Simon & Schuster", ISBN = "978-0743269513", Classification = "Non-Fiction", Category = "Self-Help", Price = 28.99, Page = 448 } ); context.SaveChanges(); } }
//Constructor public EFBookstoreRepository(BookstoreDbContext context) { _context = context; }
public EFBookstoreRepository(BookstoreDbContext context) //The constructor { _context = context; }
public static void EnsurePopulated(IApplicationBuilder application) { BookstoreDbContext context = application.ApplicationServices. CreateScope().ServiceProvider.GetRequiredService <BookstoreDbContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.Projects.Any()) { context.Projects.AddRange( //Creating a new entry for the database new Project { Title = "Les Miserables", AuthorFirstName = "Victor", AuthorLastName = "Hugo", Publisher = "Signet", ISBN = "978-0451419439", Classification = "Fiction", Category = "Classic", Price = 9.95 }, new Project { Title = "Team of Rivals", AuthorFirstName = "Doris Kearns", AuthorLastName = "Goodwin", Publisher = "Simon & Schuster", ISBN = "978-0743270755", Classification = "Non-Fiction", Category = "Biography", Price = 14.58 }, new Project { Title = "The Snowball", AuthorFirstName = "Alice", AuthorLastName = "Schroeder", Publisher = "Bantam", ISBN = "978-0553384611", Classification = "Non-Fiction", Category = "Biography", Price = 21.54 }, new Project { Title = "American Ulysses", AuthorFirstName = "Ronald C.", AuthorLastName = "White", Publisher = "Random House", ISBN = "978-0812981254", Classification = "Non-Fiction", Category = "Biography", Price = 11.61 }, new Project { Title = "Unbroken", AuthorFirstName = "Laura", AuthorLastName = "Hillenbrand", Publisher = "Random House", ISBN = "978-0812974492", Classification = "Non-Fiction", Category = "Historical", Price = 13.33 }, new Project { Title = "The Great Train Robbery", AuthorFirstName = "Michael", AuthorLastName = "Crichton", Publisher = "Vintage", ISBN = "978-0804171281", Classification = "Fiction", Category = "Historical Fiction", Price = 15.95 }, new Project { Title = "Deep Work", AuthorFirstName = "Cal", AuthorLastName = "Newport", Publisher = "Grand Central Publishing", ISBN = "978-1455586691", Classification = "Non-Fiction", Category = "Self-Help", Price = 14.99 }, new Project { Title = "It's Your Ship", AuthorFirstName = "Michael", AuthorLastName = "Abrashoff", Publisher = "Grand Central Publishing", ISBN = "978-1455523023", Classification = "Non-Fiction", Category = "Self-Help", Price = 21.66 }, new Project { Title = "The Virgin Way", AuthorFirstName = "Richard", AuthorLastName = "Branson", Publisher = "Portfolio", ISBN = "978-1591847984", Classification = "Non-Fiction", Category = "Business", Price = 29.16 }, new Project { Title = "Sycamore Row", AuthorFirstName = "John", AuthorLastName = "Grisham", Publisher = "Bantam", ISBN = "978-0553393613", Classification = "Fiction", Category = "Thrillers", Price = 15.03 } ); context.SaveChanges(); } }
public static void EnsurePopulated(IApplicationBuilder application) { //Migrates BookstoreDbContext context = application.ApplicationServices. CreateScope().ServiceProvider.GetRequiredService <BookstoreDbContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.Books.Any()) { context.Books.AddRange( //Seeds Data new Book { Title = "Les Miserables", AuthorFirstName = "Victor", AuthorLastName = "Hugo", Publisher = "Signet", ISBN = "978-0451419439", Classification = "Fiction", Category = "Classic", Price = 9.95, PageNum = 1488 }, new Book { Title = "Team of Rivals", AuthorFirstName = "Doris Kearns", AuthorLastName = "Goodwin", Publisher = "Simon & Schuster", ISBN = "978-07432707559", Classification = "Non-Fiction", Category = "Biography", Price = 14.58, PageNum = 944 }, new Book { Title = "The Snowball", AuthorFirstName = "Alice", AuthorLastName = "Schroeder", Publisher = "Bantam", ISBN = "978-0553384611", Classification = "Non-Fiction", Category = "Biography", Price = 21.54, PageNum = 832 }, new Book { Title = "American Ulysses", AuthorFirstName = "Ronald C.", AuthorLastName = "White", Publisher = "Random House", ISBN = "978-0812981254", Classification = "Non-Fiction", Category = "Biography", Price = 11.61, PageNum = 864 }, new Book { Title = "Unbroken", AuthorFirstName = "Laura", AuthorLastName = "Hillenbrand", Publisher = "Random House", ISBN = "978-0812974492", Classification = "Non-Fiction", Category = "Historical", Price = 13.33, PageNum = 528 }, new Book { Title = "The Great Train Robbery", AuthorFirstName = "Michael", AuthorLastName = "Chrichton", Publisher = "Vintage", ISBN = "978-0804171281", Classification = "Fiction", Category = "Historical Fiction", Price = 15.95, PageNum = 288 }, new Book { Title = "Deep Work", AuthorFirstName = "Cal", AuthorLastName = "Newport", Publisher = "Grand Central Publishing", ISBN = "978-1455586691", Classification = "Non-Fiction", Category = "Self-Help", Price = 14.99, PageNum = 304 }, new Book { Title = "It's Your Ship", AuthorFirstName = "Michael", AuthorLastName = "Abrashoff", Publisher = "Grand Central Publishing", ISBN = "978-1455523023", Classification = "Non-Fiction", Category = "Self-Help", Price = 21.66, PageNum = 240 }, new Book { Title = "The Virgin Way", AuthorFirstName = "Richard", AuthorLastName = "Branson", Publisher = "Portfolio", ISBN = "978-1591847984", Classification = "Non-Fiction", Category = "Business", Price = 29.16, PageNum = 400 }, new Book { Title = "Sycamore Row", AuthorFirstName = "John", AuthorLastName = "Grisham", Publisher = "Bantam", ISBN = "978-0553393613", Classification = "Fiction", Category = "Thrillers", Price = 15.03, PageNum = 642 }, new Book { Title = "Hunger Games", AuthorFirstName = "Suzanne", AuthorLastName = "Collins", Publisher = "Scholastic Corporation", ISBN = "978-055339238", Classification = "Fiction", Category = "Fantasy", Price = 8.53, PageNum = 250 }, new Book { Title = "How to Win Friends and Influence People", AuthorFirstName = "Dale", AuthorLastName = "Carnegie", Publisher = "Simon & Schuster", ISBN = "978-0553393746", Classification = "Non-Fiction", Category = "Business", Price = 8.49, PageNum = 175 }, new Book { Title = "Harry Potter", AuthorFirstName = "J.K.", AuthorLastName = "Rowling", Publisher = "Bloomsbury Publishing", ISBN = "978-0553393876", Classification = "Fiction", Category = "Fantasy", Price = 12.03, PageNum = 683 } ); context.SaveChanges(); } }
public static void EnsurePopulated(IApplicationBuilder application) { BookstoreDbContext context = application.ApplicationServices.CreateScope().ServiceProvider.GetRequiredService <BookstoreDbContext>(); if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } if (!context.Books.Any()) { context.Books.AddRange( new Book { Title = "Les Miserables", Author = "Victor Hugo", Publisher = "Signet", ISBN = "978-0451419439", Classification = "Fiction", Category = "Classic", Price = 9.95, NumPages = 1488 }, new Book { Title = "Team of Rivals", Author = "Doris Kearns Goodwin", Publisher = "Simon & Schuster", ISBN = "978-0743270755", Classification = "Non-Fiction", Category = "Biography", Price = 15.58, NumPages = 944 }, new Book { Title = "The Snowball", Author = "Alice Schroeder", Publisher = "Bantam", ISBN = "978-0553384611", Classification = "Non-Fiction", Category = "Biography", Price = 21.54, NumPages = 832 }, new Book { Title = "American Ulysses", Author = "Ronald C. White", Publisher = "Random House", ISBN = "978-0812981254", Classification = "Non-Fiction", Category = "Biography", Price = 11.61, NumPages = 864 }, new Book { Title = "Unbroken", Author = "Laura Hillenbrand", Publisher = "Random House", ISBN = "978-0812974492", Classification = "Non-Fiction", Category = "Historical", Price = 13.33, NumPages = 528 }, new Book { Title = "The Great Train Robbery", Author = "Michael Crichton", Publisher = "Vintage", ISBN = "978-0804171281", Classification = "Fiction", Category = "Historical Fiction", Price = 15.95, NumPages = 288 }, new Book { Title = "Deep Work", Author = "Cal Newport", Publisher = "Grand Central Publishing", ISBN = "978-1455586691", Classification = "Non-Fiction", Category = "Self-Help", Price = 14.99, NumPages = 304 }, new Book { Title = "It's Your Ship", Author = "Michael Abrashoff", Publisher = "Grand Central Publishing", ISBN = "978-1455523023", Classification = "Non-Fiction", Category = "Self-Help", Price = 21.66, NumPages = 240 }, new Book { Title = "The Virgin Way", Author = "Richard Branson", Publisher = "Portfolio", ISBN = "978-1591847984", Classification = "Non-Fiction", Category = "Business", Price = 29.16, NumPages = 400 }, new Book { Title = "Sycamore Row", Author = "John Grisham", Publisher = "Bantam", ISBN = "978-0553393613", Classification = "Fiction", Category = "Thriller", Price = 15.03, NumPages = 642 }, new Book { Title = "Harry Potter and the Deathly Hallows", Author = "J.K. Rowling", Publisher = "Bloomsbury Publishing", ISBN = "978-0545029377", Classification = "Fiction", Category = "Mystery", Price = 13.86, NumPages = 607 }, new Book { Title = "The Westing Game", Author = "Ellen Raskin", Publisher = "Puffin Books", ISBN = "978-0142401200", Classification = "Fiction", Category = "Mystery", Price = 7.99, NumPages = 216 }, new Book { Title = "The Infinite Atonement", Author = "Tad R. Callister", Publisher = "Deseret Book Co", ISBN = "978-1573456234", Classification = "Non-Fiction", Category = "Religious", Price = 24.99, NumPages = 356 } ); context.SaveChanges(); } }