Ejemplo n.º 1
0
        public void DbInitialize(Rema1000Context context)
        {
            if (context.Product.Any() && context.Product.Any() && context.Category.Any())
            {
                return;   // DB has been seeded
            }

            var categories = new Category[]
            {
                new Category {
                    Name = "Clothes", Description = "bla"
                },
                new Category {
                    Name = "Food", Description = "bla1"
                },
                new Category {
                    Name = "Utilities", Description = "bla2"
                }
            };

            var suppliers = new Supplier[]
            {
                new Supplier {
                    Name    = "Coop", Address = "Whateverstan 2000", ZipCode = 1000,
                    Contact = "Karl-Johan", Email = "*****@*****.**", PhoneNumber = 20202020
                },
                new Supplier {
                    Name    = "Tøj-r-us", Address = "Whereeverstan 100", ZipCode = 2000,
                    Contact = "Søren", Email = "*****@*****.**", PhoneNumber = 30303030
                },
                new Supplier {
                    Name    = "Util Supplies", Address = "herestan 300", ZipCode = 3000,
                    Contact = "Lars", Email = "*****@*****.**", PhoneNumber = 40404040
                },
            };

            var products = new Product[]
            {
                new Product {
                    Name   = "Kjole", Description = "A nice dress", Unit = 1,
                    Amount = 1, Price = 1499, Category = categories[0], Stock = 100, Supplier = suppliers[1]
                },

                new Product {
                    Name   = "Trøje", Description = "A nice sweater", Unit = 2,
                    Amount = 1, Price = 500, Category = categories[0], Stock = 50, Supplier = suppliers[1]
                },

                new Product {
                    Name   = "Frysepizza", Description = "Quite Delicious", Unit = 1,
                    Amount = 2, Price = 100, Category = categories[1], Stock = 20, Supplier = suppliers[0]
                },

                new Product {
                    Name   = "Bukser", Description = "A nice set of pants", Unit = 1,
                    Amount = 1, Price = 999, Category = categories[0], Stock = 30, Supplier = suppliers[1]
                },

                new Product {
                    Name   = "Parisertoast", Description = "Very delicious!", Unit = 1,
                    Amount = 1, Price = 30, Category = categories[1], Stock = 10, Supplier = suppliers[0]
                },

                new Product {
                    Name   = "Lagsagne", Description = "Even more delicious!", Unit = 1,
                    Amount = 1, Price = 1499, Category = categories[1], Stock = 100, Supplier = suppliers[0]
                },

                new Product {
                    Name   = "Elpærer", Description = "For when you get bright ideas", Unit = 1,
                    Amount = 3, Price = 30, Category = categories[2], Stock = 10, Supplier = suppliers[2]
                },

                new Product {
                    Name   = "Skruetrækker", Description = "Just say screw it!", Unit = 1,
                    Amount = 1, Price = 50, Category = categories[2], Stock = 100, Supplier = suppliers[2]
                },

                new Product {
                    Name   = "Ovnrens", Description = "Clean that oven!", Unit = 1,
                    Amount = 1, Price = 1499, Category = categories[2], Stock = 100, Supplier = suppliers[2]
                },

                new Product {
                    Name   = "Klovborg ost", Description = "Gotta love me some solidified milk!", Unit = 1,
                    Amount = 1, Price = 60, Category = categories[1], Stock = 10, Supplier = suppliers[1]
                },
            };

            context.AddRange(categories);
            context.AddRange(suppliers);
            context.AddRange(products);

            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public void DbInitialize(Rema1000Context context)
        {
            if (context.Products.Any())
            {
                return;   // DB has been seeded
            }

            var Categories = new Category[]
            {
                new Category {
                    Name = "Clothes", Description = "bla"
                },
                new Category {
                    Name = "Toys", Description = "bla1"
                },
                new Category {
                    Name = "Grocery", Description = "bla2"
                }
            };

            var Suppliers = new Supplier[]
            {
                new Supplier {
                    Name = "Bob´s virksomhed", Address = "bobvej", Postcode = 1234, ContactPerson = "Bob", Email = "*****@*****.**", Phone = 123456
                },
                new Supplier {
                    Name = "Manfreds´s virksomhed", Address = "aManfredvej", Postcode = 4321, ContactPerson = "Manfred", Email = "*****@*****.**", Phone = 654321
                },
            };

            var Products = new Product[]
            {
                new Product {
                    Name        = "Kjole",
                    Description = "a good looking dress", Unit = 1, UnitCount = 1, Price = 19.99, Category = Categories[0], Stock = 10, Supplier = Suppliers[0]
                },

                new Product {
                    Name        = "Trøje",
                    Description = "A good looking sweater", Unit = 1, UnitCount = 1, Price = 9.99, Category = Categories[0], Stock = 15, Supplier = Suppliers[0]
                },

                new Product {
                    Name        = "Jeans Busker",
                    Description = "A good looking Denim Jeans", Unit = 1, UnitCount = 1, Price = 35.95, Category = Categories[0], Stock = 5, Supplier = Suppliers[0]
                },

                new Product {
                    Name        = "Legetøjs-bil",
                    Description = "Legetøj", Unit = 1, UnitCount = 1, Price = 10.00, Category = Categories[1], Stock = 3, Supplier = Suppliers[0]
                },

                new Product {
                    Name        = "Legetøjs-båd",
                    Description = "Legetøj", Unit = 1, UnitCount = 1, Price = 15.00, Category = Categories[1], Stock = 13, Supplier = Suppliers[0]
                },

                new Product {
                    Name        = "Vandpistol",
                    Description = "Legetøj", Unit = 1, UnitCount = 1, Price = 20.00, Category = Categories[1], Stock = 23, Supplier = Suppliers[0]
                },

                new Product {
                    Name        = "Milk",
                    Description = "Fresh Milk", Unit = 1, UnitCount = 1, Price = 2.99, Category = Categories[2], Stock = 100, Supplier = Suppliers[1]
                },

                new Product {
                    Name        = "banan",
                    Description = "Frugt", Unit = 1, UnitCount = 5, Price = 3.99, Category = Categories[2], Stock = 20, Supplier = Suppliers[1]
                },
            };

            context.AddRange(Categories);
            context.AddRange(Suppliers);
            context.AddRange(Products);

            context.SaveChanges();
        }