Пример #1
0
        public async Task InitializeData()
        {
            Console.WriteLine("Removing existing gardens.");
            _dbContext.Database.EnsureDeleted();
            Console.WriteLine("Making final touches to the gardens.");
            if (_dbContext.Database.EnsureCreated())
            {
                Console.WriteLine("Admiring the finished gardens after a long hot day of digging soil.");
                Console.WriteLine();
                Console.WriteLine("Searching for gardeners.");
                Gebruiker gebruiker = new Gebruiker {
                    Email = "*****@*****.**", FirstName = "Glenn", LastName = "Beeckman"
                };
                _dbContext.Add(gebruiker);

                await CreateGebruiker(gebruiker.Email, "P@ssword1234");

                Console.WriteLine("Found one");
                Console.WriteLine();
                Console.WriteLine("User: [email protected]");
                Console.WriteLine("Password: P@ssword1234");

                Gebruiker student = new Gebruiker {
                    Email = "*****@*****.**", FirstName = "Student", LastName = "Hogent"
                };
                _dbContext.Add(student);

                student.AddFavoriteTuin(_dbContext.Tuinen.First());

                await CreateGebruiker(student.Email, "P@ssword1234");

                Console.WriteLine();
                Console.WriteLine("Found another");
                Console.WriteLine("User: [email protected]");
                Console.WriteLine("Password: P@ssword1234");
                Console.WriteLine();
                _dbContext.SaveChanges();
            }
        }