public void Seed(IteraLibraryDbContext dbContext)
 {
     #if DEBUG
     // Create my debug (testing) objects here
     #endif
     // Normal seeding goes here
     SeedData.SeedBooks(dbContext);
 }
示例#2
0
        public static void SeedProducts(IteraLibraryDbContext dbContext)
        {
            var assembly      = Assembly.GetExecutingAssembly();
            var resourceNames = assembly.GetManifestResourceNames();
            var products      = new List <Product>();

            foreach (var resourceName in resourceNames)
            {
                if (resourceName.EndsWith(".txt"))
                {
                    using (var stream = assembly.GetManifestResourceStream(resourceName))
                    {
                        using (TextReader reader = new StreamReader(stream, Encoding.UTF8))
                        {
                            var text     = reader.ReadToEnd();
                            var splitted = text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
                            products.Add(new Product
                            {
                                Price       = Convert.ToDouble(splitted[0]),
                                Name        = splitted[1],
                                Description = splitted[2],
                                ImageName   = resourceName.Substring(36).Replace("txt", "jpg"),

                                Brand   = splitted[3],
                                Variant = splitted[4],
                                SizeMin = Convert.ToInt32(splitted[5]),
                                SizeMax = Convert.ToInt32(splitted[6]),
                                Number  = resourceName.Substring(36).Replace(".txt", ""),
                            });
                        }
                    }
                }
            }

            foreach (var product in products)
            {
                dbContext.Products.Add(product);
            }
        }
        public static void SeedBooks(IteraLibraryDbContext dbContext)
        {
            //dbContext.Books.Add(new Book
            //{
            //    BookId = 1,
            //    Author = "Robert C. Martin",
            //    Title = "Clean Code",
            //    Description = "Even bad code can function. But if code isn’t clean, it can bring a development organization to its knees. Every year, countless hours and significant resources are lost because of poorly written code. But it doesn’t have to be that way. Noted software expert Robert C. Martin presents a revolutionary paradigm with Clean Code: A Handbook of Agile Software Craftsmanship. Martin has teamed up with his colleagues from Object Mentor to distill their best agile practice of cleaning code “on the fly” into a book that will instill within you the values of a software craftsman and make you a better programmer—but only if you work at it. What kind of work will you be doing? You’ll be reading code—lots of code. And you will be challenged to think about what’s right about that code, and what’s wrong with it. More importantly, you will be challenged to reassess your professional values and your commitment to your craft.",
            //    CoverImageUrl = "~/Resources/Uploads/CleanCode.jpg",
            //    Language = "English",
            //    Pages = 464,
            //    ISBN10 = "0132350882",
            //    ISBN13 = "978-0132350884"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 2,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 3,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});


            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});

            //dbContext.Books.Add(new Book
            //{
            //    BookId = 4,
            //    Author = "Roy Osherove",
            //    Title = "The Art of Unit Testing",
            //    Description = "Developers know they \"should\" be unit testing, but it can be intimidating and tedious, and they don't always see the payoff for the effort they put into it. The Art of Unit Testing, Second Edition is a step-by-step guide that helps reluctant developers learn how to write simple tests and leads them through developing robust test sets that are maintainable, readable, and trustworthy. Readers will explore test patterns and organization, working with legacy code, and even \"untestable\" code. Along the way, they'll learn about integration testing and techniques and tools for testing databases and other technologies.",
            //    CoverImageUrl = "~/Resources/Uploads/TheArtOfUnitTesting.jpg",
            //    Language = "English",
            //    Pages = 375,
            //    ISBN10 = "1617290890",
            //    ISBN13 = "978-1617290893"
            //});
        }