Exemple #1
0
        public static void Initialize(WebBasicsDBContext context)
        {
            context.Database.EnsureCreated();

            if (context.Cats.Any())
            {
                if (context.Dogs.Any())
                {
                    return;
                }
                context.Dogs.AddRange(new Entities.Dog[] {
                    new Entities.Dog()
                    {
                        Name = "Dog1", Age = 4
                    },
                    new Entities.Dog()
                    {
                        Name = "Dog2", Age = 6
                    },
                    new Entities.Dog()
                    {
                        Name = "Dog3", Age = 7
                    },
                    new Entities.Dog()
                    {
                        Name = "Dog4", Age = 9
                    }
                });
                context.SaveChanges();
                return;
            }

            context.Cats.AddRange(new Entities.Cat[] {
                new Entities.Cat()
                {
                    Name = "Barsik", Age = 3
                },
                new Entities.Cat()
                {
                    Name = "Kozkii", Age = 4
                },
                new Entities.Cat()
                {
                    Name = "Murka", Age = 13
                },
                new Entities.Cat()
                {
                    Name = "Bony", Age = 2
                }
            });

            context.SaveChanges();
        }
        public static void Initialize(WebBasicsDBContext context)
        {
            context.Database.EnsureCreated();
            if (!cats)
            {
                if (!context.Cats.Any())
                {
                    context.Cats.AddRange(new Cat {
                        Name = "Barsik", Age = 3
                    }, new Cat {
                        Name = "Kozkii", Age = 4
                    },
                                          new Cat {
                        Name = "Murka", Age = 13
                    }, new Cat {
                        Name = "Bony", Age = 2
                    });
                    cats = true;
                }
            }

            if (!accounts)
            {
                if (!context.Accounts.Any())
                {
                    context.Accounts.AddRange(
                        new Account {
                        Email = "*****@*****.**", Password = "******", Role = Role.User
                    },
                        new Account {
                        Email = "*****@*****.**", Password = "******", Role = Role.User
                    },
                        new Account {
                        Email = "*****@*****.**", Password = "******", Role = Role.Admin
                    });
                    accounts = true;
                }
            }

            if (!owners)
            {
                if (!context.Owners.Any())
                {
                    context.Owners.AddRange(new Owner {
                        UserId = 1, CatId = 1
                    }, new Owner {
                        UserId = 2, CatId = 3
                    },
                                            new Owner {
                        UserId = 2, CatId = 4
                    });
                    owners = true;
                }
            }

            context.SaveChanges();
        }
        public static void Initialize(WebBasicsDBContext context)
        {
            context.Database.EnsureCreated();

            if (!context.Cats.Any())
            {
                context.Cats.AddRange(new Entities.Cat[] {
                    new Entities.Cat()
                    {
                        Name = "Barsik", Age = 3
                    },
                    new Entities.Cat()
                    {
                        Name = "Kozkii", Age = 4
                    },
                    new Entities.Cat()
                    {
                        Name = "Murka", Age = 13
                    },
                    new Entities.Cat()
                    {
                        Name = "Bony", Age = 2
                    }
                });
            }

            if (!context.Dogs.Any())
            {
                context.Dogs.AddRange(new Entities.Dog[] {
                    new Entities.Dog()
                    {
                        Name = "Bella", Age = 5
                    },
                    new Entities.Dog()
                    {
                        Name = "Charlie", Age = 3
                    },
                    new Entities.Dog()
                    {
                        Name = "Luna", Age = 6
                    },
                    new Entities.Dog()
                    {
                        Name = "Palpatine", Age = 10
                    }
                });
            }

            context.SaveChanges();
        }
        public static void Initialize(WebBasicsDBContext context)
        {
            context.Database.EnsureCreated();

            if (!context.Cats.Any())
            {
                context.Cats.AddRange(new Entities.Cat[] {
                    new Entities.Cat()
                    {
                        Name = "Barsik", Age = 3
                    },
                    new Entities.Cat()
                    {
                        Name = "Kozkii", Age = 4
                    },
                    new Entities.Cat()
                    {
                        Name = "Murka", Age = 13
                    },
                    new Entities.Cat()
                    {
                        Name = "Bony", Age = 2
                    }
                });
            }

            if (!context.Dogs.Any())
            {
                context.Dogs.AddRange(new Entities.Dog[] {
                    new Entities.Dog()
                    {
                        Name = "Muhtar", Age = 3
                    },
                    new Entities.Dog()
                    {
                        Name = "Sharik", Age = 4
                    },
                    new Entities.Dog()
                    {
                        Name = "Brutt", Age = 10
                    },
                    new Entities.Dog()
                    {
                        Name = "Mike", Age = 5
                    }
                });
            }

            context.SaveChanges();
        }
        public static void Initialize(WebBasicsDBContext context)
        {
            context.Database.EnsureCreated();

            if (!context.Cats.Any())
            {
                context.Cats.AddRange(new Entities.Cat[] {
                    new Entities.Cat()
                    {
                        Name = "Barsik", Age = 3
                    },
                    new Entities.Cat()
                    {
                        Name = "Kozkii", Age = 4
                    },
                    new Entities.Cat()
                    {
                        Name = "Murka", Age = 13
                    },
                    new Entities.Cat()
                    {
                        Name = "Bony", Age = 2
                    }
                });
            }

            if (!context.Accounts.Any())
            {
                context.Accounts.AddRange(new Entities.Account[] {
                    new Entities.Account()
                    {
                        Email = "*****@*****.**", Password = "******", Role = Role.User
                    },
                    new Entities.Account()
                    {
                        Email = "*****@*****.**", Password = "******", Role = Role.User
                    },
                    new Entities.Account()
                    {
                        Email = "*****@*****.**", Password = "******", Role = Role.User
                    },
                    new Entities.Account()
                    {
                        Email = "*****@*****.**", Password = "******", Role = Role.User
                    },
                    new Entities.Account()
                    {
                        Email = "*****@*****.**", Password = "******", Role = Role.User
                    },
                    new Entities.Account()
                    {
                        Email = "*****@*****.**", Password = "******", Role = Role.User
                    },
                    new Entities.Account()
                    {
                        Email = "*****@*****.**", Password = "******", Role = Role.Admin
                    }
                });
            }

            if (!context.Owners.Any())
            {
                context.Owners.AddRange(new Entities.Owner[] {
                    new Entities.Owner()
                    {
                        UserId = 1, CatId = 1
                    },
                    new Entities.Owner()
                    {
                        UserId = 2, CatId = 3
                    },
                    new Entities.Owner()
                    {
                        UserId = 2, CatId = 4
                    }
                });
            }

            context.SaveChanges();
        }