Beispiel #1
0
        public static void Seed(ArtStoreDbContext db)
        {
            if (!db.Shops.Any())
            {
                var owners = db
                             .Users
                             .Where(u => u.IsShopOwner == true)
                             .ToList();

                var shops = new List <Shop>
                {
                    new Shop
                    {
                        Description = "Best shop in the world. Must Visit",
                        Name        = "Galaxy sheep",
                        OwnerId     = 2,
                        DateCreated = DateTime.Now
                    },
                    new Shop
                    {
                        Description = "Please buy my things, I need money to eat",
                        Name        = "Hipster extravaganza",
                        OwnerId     = 3,
                        DateCreated = DateTime.Now
                    }
                };

                db.AddRange(shops);
                db.SaveChanges();
            }
        }
Beispiel #2
0
        public static void Seed(ArtStoreDbContext db)
        {
            if (!db.Users.Any())
            {
                var users = new List <User>
                {
                    new User
                    {
                        Username  = "******",
                        Password  = "******",
                        Email     = "*****@*****.**",
                        FirstName = "Dannie",
                        LastName  = "Vasileva",
                        IsAdmin   = true
                    },
                    new User
                    {
                        Username    = "******",
                        Password    = "******",
                        Email       = "*****@*****.**",
                        FirstName   = "Rali",
                        LastName    = "Vasileva",
                        IsShopOwner = true
                    },
                    new User
                    {
                        Username    = "******",
                        Password    = "******",
                        Email       = "*****@*****.**",
                        FirstName   = "Arthur",
                        LastName    = "The Cat",
                        IsShopOwner = true
                    },
                    new User
                    {
                        Username  = "******",
                        Password  = "******",
                        Email     = "*****@*****.**",
                        FirstName = "Sisi",
                        LastName  = "The Cat",
                    },
                };

                db.AddRange(users);
                db.SaveChanges();
            }
        }
Beispiel #3
0
        public static void Seed(ArtStoreDbContext db)
        {
            if (!db.ItemsForSale.Any())
            {
                var items = new List <ItemForSale>
                {
                    new ItemForSale
                    {
                        Title       = "Witchy Sticker Sheet # 1",
                        Description = "Compilation of cute stickers",
                        Price       = 4.5m,
                        ShopId      = 1,
                        SellerId    = 2,
                        DateCreated = DateTime.Now
                    },
                    new ItemForSale
                    {
                        Title       = "Witchy Sticker Sheet # 2",
                        Description = "Next generation cute stickers",
                        Price       = 5m,
                        ShopId      = 1,
                        SellerId    = 2,
                        DateCreated = DateTime.Now
                    },
                    new ItemForSale
                    {
                        Title       = "Mina Lisa",
                        Description = "Like, totally not a fake!!",
                        Price       = 20000m,
                        ShopId      = 2,
                        SellerId    = 3,
                        DateCreated = DateTime.Now
                    },
                };

                db.AddRange(items);
                db.SaveChanges();
            }
        }