private void SeedDatabase()
        {
            var context = new GlovoDbContext(ContextOptions);

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            _users = new List <User>()
            {
                new User("u1", "*****@*****.**", "password-u1", new Location(0, 0), UserRole.Regular)
                {
                    Id = 1
                },
                new User("u2", "*****@*****.**", "password-u2", new Location(0, 0), UserRole.Regular)
                {
                    Id = 2
                },
                new User("a1", "*****@*****.**", "password-a1", new Location(0, 0), UserRole.Administrator)
                {
                    Id = 3
                }
            };

            context.AddRange(_users);
            context.SaveChanges();
        }
Example #2
0
        private void SeedDatabase()
        {
            var context = new GlovoDbContext(ContextOptions);

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            _restaurants = new List <Restaurant>()
            {
                new Restaurant("name-r1", "imgPath-u1", new Location(1, 0))
                {
                    Id = 1
                },
                new Restaurant("name-r2", "imgPath-u2", new Location(2, 0))
                {
                    Id = 2
                },
                new Restaurant("name-r3", "imgPath-u3", new Location(3, 0))
                {
                    Id = 3
                },
                new Restaurant("name-r4", "imgPath-u4", new Location(4, 0))
                {
                    Id = 4
                },
                new Restaurant("name-r5", "imgPath-u5", new Location(5, 0))
                {
                    Id = 5
                }
            };

            context.AddRange(_restaurants);
            context.SaveChanges();
        }
Example #3
0
        private void SeedDatabase()
        {
            var context = new GlovoDbContext(ContextOptions);

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            _restaurants = new List <Restaurant>()
            {
                new Restaurant("name-r1", "imgPath-u1", new Location(1, 0))
                {
                    Id = 1
                },
                new Restaurant("name-r2", "imgPath-u2", new Location(2, 0))
                {
                    Id = 2
                }
            };
            _products = new List <Product>()
            {
                new Product("name-p1", "imgPath-p1", "desc-p1", 10, 1, "Menu")
                {
                    Id = 1
                },
                new Product("name-p2", "imgPath-p2", "desc-p2", 20, 2, "Menu")
                {
                    Id = 2
                },
                new Product("name-p3", "imgPath-p3", "desc-p3", 5, 2, "Menu")
                {
                    Id = 3
                },
                new Product("name-p4", "imgPath-p4", "desc-p4", 15, 2, "Menu")
                {
                    Id = 4
                },
                new Product("name-p5", "imgPath-p5", "desc-p5", 12, 2, "Menu")
                {
                    Id = 5
                }
            };

            context.AddRange(_restaurants);
            context.SaveChanges();
            context.AddRange(_products);
            context.SaveChanges();
        }
        private void SeedDatabase()
        {
            var context = new GlovoDbContext(ContextOptions);

            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            _restaurants = new List <Restaurant>()
            {
                new Restaurant("name-r1", "imgPath-u1", new Location(1, 0))
                {
                    Id = 1
                },
                new Restaurant("name-r2", "imgPath-u2", new Location(2, 0))
                {
                    Id = 2
                }
            };
            _products = new List <Product>()
            {
                new Product("name-p1", "imgPath-p1", "desc-p1", 10, 1, "Menu")
                {
                    Id = 1
                },
                new Product("name-p2", "imgPath-p2", "desc-p2", 20, 2, "Menu")
                {
                    Id = 2
                },
                new Product("name-p3", "imgPath-p3", "desc-p3", 5, 2, "Menu")
                {
                    Id = 3
                },
                new Product("name-p4", "imgPath-p4", "desc-p4", 15, 2, "Menu")
                {
                    Id = 4
                },
                new Product("name-p5", "imgPath-p5", "desc-p5", 12, 2, "Menu")
                {
                    Id = 5
                }
            };
            _users = new List <User>()
            {
                new User("u1", "*****@*****.**", "password-u1", new Location(0, 0), UserRole.Regular)
                {
                    Id = 1
                },
                new User("u2", "*****@*****.**", "password-u2", new Location(0, 0), UserRole.Regular)
                {
                    Id = 2
                },
                new User("a1", "*****@*****.**", "password-a1", new Location(0, 0), UserRole.Administrator)
                {
                    Id = 3
                }
            };
            _orders = new List <Order>()
            {
                new Order(DateTime.Parse("2020-01-01 12:00:00"), 1, 1)
                {
                    Id = 1
                },
                new Order(DateTime.Parse("2020-01-02 12:00:00"), 1, 2)
                {
                    Id = 2
                },
                new Order(DateTime.Parse("2020-01-03 12:00:00"), 2, 2)
                {
                    Id = 3
                }
            };
            _orderProducts = new List <OrderProduct>()
            {
                new OrderProduct(1, 1, 5),
                new OrderProduct(2, 2, 5),
                new OrderProduct(3, 2, 2),
                new OrderProduct(3, 3, 3),
                new OrderProduct(3, 4, 4),
                new OrderProduct(3, 5, 5)
            };

            context.AddRange(_restaurants);
            context.SaveChanges();
            context.AddRange(_products);
            context.SaveChanges();
            context.AddRange(_users);
            context.SaveChanges();
            context.AddRange(_orders);
            context.SaveChanges();
            context.AddRange(_orderProducts);
            context.SaveChanges();
        }