예제 #1
0
        public async Task <string> Seed()
        {
            int numberOfCars = 0;

            if (_context.Car.Count() == 0)
            {
                Car car1 = new Car {
                    Make = "Toyota", Model = "Corolla", Colour = "Blue", Year = 2011, VIN = 123
                };
                Car car2 = new Car {
                    Make = "Honda", Model = "Civic", Colour = "Red", Year = 2012, VIN = 456
                };
                Car car3 = new Car {
                    Make = "Nissan", Model = "Altima", Colour = "Green", Year = 2018, VIN = 789
                };
                Car car4 = new Car {
                    Make = "Mazda", Model = "Mazda3", Colour = "Silver", Year = 2010, VIN = 321
                };

                _context.AddRange(car1, car2, car3, car4);
                await _context.SaveChangesAsync();

                numberOfCars = 4;
            }

            return($"{numberOfCars} Cars Added");
        }
예제 #2
0
        private void Seed()
        {
            var rand = new Random();

            using var context = new WebApiContext(DbContextOptions);

            var groups = context.UserGroups.Select(g => g.Id).ToList();
            var states = context.UserStates.Select(s => s.Id).ToList();

            var usersToAdd = new List <User>();

            for (var i = 0; i < 10; i++)
            {
                usersToAdd.Add(new User
                {
                    Login        = rand.Next().ToString(),
                    PasswordHash = rand.Next().ToString(),
                    Salt         = rand.Next().ToString(),
                    CreatedDate  = DateTime.Now - TimeSpan.FromSeconds(rand.Next()),
                    GroupId      = groups[rand.Next(groups.Count)],
                    StateId      = states[rand.Next(states.Count)]
                });
            }

            context.AddRange(usersToAdd);
            context.SaveChanges();
        }
예제 #3
0
        public async Task <string> Seed()
        {
            int numberOfMembers = 0;

            if (_context.Member.Count() == 0)
            {
                Member member1 = new Member {
                    FirstName = "James", LastName = "Bound", UserName = "******", Email = "*****@*****.**"
                };
                Member member2 = new Member {
                    FirstName = "Jack", LastName = "Wayne", UserName = "******", Email = "*****@*****.**"
                };

                _context.AddRange(member1, member2);
                await _context.SaveChangesAsync();

                numberOfMembers = 2;
            }

            return($"{numberOfMembers} Members Added");
        }
예제 #4
0
        public void Seed()
        {
            if (_context.Pessoas.Any())
            {
                return;
            }

            Pessoa p1 = new Pessoa()
            {
                Nome = "Thomas", Email = "*****@*****.**", Telefone = "94444-4444"
            };
            Pessoa p2 = new Pessoa()
            {
                Nome = "Ana", Email = "*****@*****.**", Telefone = "95555-4444"
            };
            Pessoa p3 = new Pessoa()
            {
                Nome = "Gabriel", Email = "*****@*****.**", Telefone = "96666-4444"
            };
            Pessoa p4 = new Pessoa()
            {
                Nome = "Helena", Email = "*****@*****.**", Telefone = "97777-4444"
            };
            Pessoa p5 = new Pessoa()
            {
                Nome = "João", Email = "Joã[email protected]", Telefone = "98888-4444"
            };
            Pessoa p6 = new Pessoa()
            {
                Nome = "Maria", Email = "*****@*****.**", Telefone = "99999-4444"
            };
            Pessoa p7 = new Pessoa()
            {
                Nome = "Pedro", Email = "*****@*****.**", Telefone = "99999-5555"
            };
            Pessoa p8 = new Pessoa()
            {
                Nome = "José", Email = "*****@*****.**", Telefone = "96666-4465"
            };
            Pessoa p9 = new Pessoa()
            {
                Nome = "Manoel", Email = "*****@*****.**", Telefone = "96666-4444"
            };
            Pessoa p10 = new Pessoa()
            {
                Nome = "Carlos", Email = "*****@*****.**", Telefone = "96666-4014"
            };
            Pessoa p11 = new Pessoa()
            {
                Nome = "Marcos", Email = "*****@*****.**", Telefone = "96666-4104"
            };
            Pessoa p12 = new Pessoa()
            {
                Nome = "Maria", Email = "*****@*****.**", Telefone = "96666-4432"
            };
            Pessoa p13 = new Pessoa()
            {
                Nome = "Daniela", Email = "*****@*****.**", Telefone = "96666-4784"
            };
            Pessoa p14 = new Pessoa()
            {
                Nome = "Rafael", Email = "*****@*****.**", Telefone = "96666-4491"
            };
            Pessoa p15 = new Pessoa()
            {
                Nome = "Mateus", Email = "*****@*****.**", Telefone = "96666-4400"
            };

            _context.AddRange(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15);
            _context.SaveChanges();
        }