コード例 #1
0
 public DetailsModel(BookStore.Models.BookStoreContext context)
 {
     _context = context;
 }
コード例 #2
0
ファイル: Edit.cshtml.cs プロジェクト: xdcarp/BooksStore
 public EditModel(BookStore.Models.BookStoreContext context)
 {
     _context = context;
 }
コード例 #3
0
ファイル: Create.cshtml.cs プロジェクト: IreneHrt18/BookStore
 public CreateModel(BookStore.Models.BookStoreContext context)
 {
     _context = context;
 }
コード例 #4
0
 public DeleteModel(BookStore.Models.BookStoreContext context)
 {
     _context = context;
 }
コード例 #5
0
 public IndexModel(BookStore.Models.BookStoreContext context)
 {
     _context = context;
 }
コード例 #6
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new BookStoreContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <BookStoreContext> >()))
            {
                // Look for any movies.
                if (context.Book.Any())
                {
                    return;   // DB has been seeded
                }

                context.Book.AddRange(
                    new Book
                {
                    Author     = "Diana Gabaldon",
                    ISBN       = "123456789",
                    Name       = "Outlander",
                    PlotReview = @" Is the first in a series of eight historical multi-genre novels by Diana Gabaldon. Published in 1991, it focuses 
                                     on the Second World War-era nurse Claire Randall, who travels through time to 18th century Scotland and finds adventure 
                                     and romance with the dashing Jamie Fraser.[1] A mix of several genres, the Outlander series has elements of historical 
                                     fiction, romance, adventure and science fiction/fantasy.",
                    Type       = "Cience Fiction"
                },
                    new Book
                {
                    Author     = "J. K. Rowling",
                    ISBN       = "23568974",
                    Name       = "Harry Potter",
                    PlotReview = @"Is a series of fantasy novels written by British author J. K. Rowling. The novels chronicle the lives of a young wizard, 
                                    Harry Potter, and his friends Hermione Granger and Ron Weasley, all of whom are students at Hogwarts School of Witchcraft and Wizardry. 
                                    The main story arc concerns Harry's struggle against Lord Voldemort, a dark wizard who intends to become immortal, overthrow the wizard 
                                    governing body known as the Ministry of Magic, and subjugate all wizards and Muggles (non-magical people).",
                    Type       = "Fantasy"
                },
                    new Book
                {
                    Author     = "Suzanne Collins",
                    ISBN       = "12562345",
                    Name       = "The Hunger Games",
                    PlotReview = @"Is a 2008 dystopian novel by the American writer Suzanne Collins. It is written in the voice of 16-year-old Katniss Everdeen, 
                                    who lives in the future, post-apocalyptic nation of Panem in North America. The Capitol, a highly advanced metropolis, 
                                    exercises political control over the rest of the nation. The Hunger Games is an annual event in which one boy and one girl 
                                    aged 12–18 from each of the twelve districts surrounding the Capitol are selected by lottery to compete in a televised 
                                    Battle royal to the death.",
                    Type       = "Distopia"
                },
                    new Book
                {
                    Author     = "Stephen King",
                    ISBN       = "7894561230",
                    Name       = "The Dark Tower",
                    PlotReview = @"It describes a ""gunslinger"" and his quest toward a tower, the nature of which is both physical and metaphorical. The series, 
                                    and its use of the Dark Tower, expands upon Stephen King's multiverse and in doing so, links together many of his other novels. 
                                    In addition to the eight novels of the series proper that comprise 4,250 pages, many of King's other books relate to the story, 
                                    introducing concepts and characters that come into play as the series progresses.",
                    Type       = "Fantasy"
                });

                context.SaveChanges();
            }
        }
コード例 #7
0
ファイル: Index.cshtml.cs プロジェクト: xdcarp/BooksStore
 public IndexModel(BookStore.Models.BookStoreContext context, BookStore.Services.IEmailService emailService)
 {
     _context      = context;
     _emailService = emailService;
 }
コード例 #8
0
        public static void EnsurePopulated(IApplicationBuilder application)
        {
            BookStoreContext context = application.ApplicationServices.
                                       CreateScope().ServiceProvider.GetRequiredService <BookStoreContext>();

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

            if (!context.Books.Any())
            {
                context.Books.AddRange(

                    new Book
                {
                    Title            = "Les Miserables",
                    AuthorFirstName  = "Victor",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Hugo",
                    Publisher        = "Signet",
                    ISBN             = "978-0451419439",
                    Fiction          = true,
                    Category         = "Classic",
                    Price            = 9.95,
                    Pages            = 1488
                },

                    new Book
                {
                    Title            = "Team of Rivals",
                    AuthorFirstName  = "Doris",
                    AuthorMiddleName = "Kearns",
                    AuthorLastName   = "Goodwin",
                    Publisher        = "Smin & Schuster",
                    ISBN             = "978-0743270755",
                    Fiction          = false,
                    Category         = "Biography",
                    Price            = 14.58,
                    Pages            = 944
                },

                    new Book
                {
                    Title            = "The Snowball",
                    AuthorFirstName  = "Alice",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Schroeder",
                    Publisher        = "Bantam",
                    ISBN             = "978-0553384611",
                    Fiction          = false,
                    Category         = "Biography",
                    Price            = 21.54,
                    Pages            = 832
                },

                    new Book
                {
                    Title            = "American Ulysses",
                    AuthorFirstName  = "Ronald",
                    AuthorMiddleName = "C.",
                    AuthorLastName   = "White",
                    Publisher        = "Random House",
                    ISBN             = "978-0812981254",
                    Fiction          = false,
                    Category         = "Biography",
                    Price            = 11.61,
                    Pages            = 864
                },

                    new Book
                {
                    Title            = "Unbroken",
                    AuthorFirstName  = "Laura",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Hillenbrand",
                    Publisher        = "Random House",
                    ISBN             = "978-0743270755",
                    Fiction          = false,
                    Category         = "Biography",
                    Price            = 13.33,
                    Pages            = 528
                },

                    new Book
                {
                    Title            = "The Great Train Robbery",
                    AuthorFirstName  = "Michael",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Crichton",
                    Publisher        = "Vintage",
                    ISBN             = "978-0804171281",
                    Fiction          = true,
                    Category         = "Historical Fiction",
                    Price            = 15.95,
                    Pages            = 288
                },

                    new Book
                {
                    Title            = "Deep Work",
                    AuthorFirstName  = "Cal",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Newport",
                    Publisher        = "Grand Central Publishing",
                    ISBN             = "978-1455586691",
                    Fiction          = false,
                    Category         = "Self-Help",
                    Price            = 14.99,
                    Pages            = 304
                },

                    new Book
                {
                    Title            = "It's Your Ship",
                    AuthorFirstName  = "Cal",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Newport",
                    Publisher        = "Grand Publishing Station",
                    ISBN             = "978-1455523023",
                    Fiction          = false,
                    Category         = "Self-Help",
                    Price            = 21.66,
                    Pages            = 240
                },

                    new Book
                {
                    Title            = "The Virgin Way",
                    AuthorFirstName  = "Richard",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Branson",
                    Publisher        = "Portfolio",
                    ISBN             = "978-1591847984",
                    Fiction          = false,
                    Category         = "Business",
                    Price            = 14.58,
                    Pages            = 400
                },

                    new Book
                {
                    Title            = "Sycamore Row",
                    AuthorFirstName  = "Doris",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Kearns",
                    Publisher        = "Smin & Schuster",
                    ISBN             = "978-0743270755",
                    Fiction          = true,
                    Category         = "Thrillers",
                    Price            = 14.58,
                    Pages            = 944
                },

                    new Book
                {
                    Title            = "The Lean Startup",
                    AuthorFirstName  = "Eric",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Ries",
                    Publisher        = "Crown Publishing Group",
                    ISBN             = "978-0307887898",
                    Fiction          = false,
                    Category         = "Business",
                    Price            = 14.50,
                    Pages            = 336
                },

                    new Book
                {
                    Title            = "Moby Dick",
                    AuthorFirstName  = "Herman",
                    AuthorMiddleName = "",
                    AuthorLastName   = "Melville",
                    Publisher        = "Richard Bently",
                    ISBN             = "978-80140861723",
                    Fiction          = true,
                    Category         = "Epic",
                    Price            = 12.13,
                    Pages            = 752
                },

                    new Book
                {
                    Title            = "Don Quixote",
                    AuthorFirstName  = "Miguel",
                    AuthorMiddleName = "de",
                    AuthorLastName   = "Cervantes",
                    Publisher        = "Penguin Classics",
                    ISBN             = "978-1400132171",
                    Fiction          = true,
                    Category         = "Satire",
                    Price            = 15.30,
                    Pages            = 863
                }

                    );
                context.SaveChanges();
            }
        }
コード例 #9
0
ファイル: ShopingCart.cs プロジェクト: madcoderBubt/BookStore
 private ShopingCart(BookStoreContext storeContext)
 {
     _dbContext = storeContext;
 }
コード例 #10
0
 public EFBookStoreRepository(BookStoreContext context)
 {
     _context = context;
 }