Exemplo n.º 1
0
        private void SeedUserSale(BreadingBreadDbContext context)
        {
            var userSales = new UserSale[]
            {
                new UserSale
                {
                    IdPath      = 1,
                    IdUser      = 1,
                    Visited     = false,
                    VisitedDate = System.DateTime.Now
                },
                new UserSale
                {
                    IdPath      = 1,
                    IdUser      = 2,
                    Visited     = false,
                    VisitedDate = System.DateTime.Now.AddDays(-1)
                },
                new UserSale
                {
                    IdPath      = 1,
                    IdUser      = 2,
                    Visited     = true,
                    VisitedDate = System.DateTime.Now.AddDays(-1)
                },
            };

            foreach (var userSale in userSales)
            {
                context.UserSale.Add(userSale);
                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
        private void SeedPathStore(BreadingBreadDbContext context)
        {
            var pathStores = new PathStore[]
            {
                new PathStore
                {
                    IdPath  = 1,
                    IdStore = 1
                },
                new PathStore
                {
                    IdPath  = 1,
                    IdStore = 2
                },
                new PathStore
                {
                    IdPath  = 1,
                    IdStore = 3
                },
                new PathStore
                {
                    IdPath  = 1,
                    IdStore = 4
                },
                new PathStore
                {
                    IdPath  = 1,
                    IdStore = 5
                },
                new PathStore
                {
                    IdPath  = 2,
                    IdStore = 1
                },
                new PathStore
                {
                    IdPath  = 2,
                    IdStore = 2
                },
                new PathStore
                {
                    IdPath  = 3,
                    IdStore = 1
                },
            };

            foreach (var pathStore in pathStores)
            {
                context.PathStore.Add(pathStore);
                context.SaveChanges();
            }
        }
Exemplo n.º 3
0
        private void SeedInventory(BreadingBreadDbContext context)
        {
            var inventories = new Inventory[]
            {
                new Inventory
                {
                    IdProduct     = 1,
                    IdSaleUser    = 1,
                    InitalCantity = 100
                },
                new Inventory
                {
                    IdProduct     = 2,
                    IdSaleUser    = 1,
                    InitalCantity = 100
                },
                new Inventory
                {
                    IdProduct     = 3,
                    IdSaleUser    = 1,
                    InitalCantity = 100
                },
                new Inventory
                {
                    IdProduct     = 4,
                    IdSaleUser    = 1,
                    InitalCantity = 100
                },
                new Inventory
                {
                    IdProduct     = 1,
                    IdSaleUser    = 2,
                    InitalCantity = 100
                },
                new Inventory
                {
                    IdProduct     = 1,
                    IdSaleUser    = 2,
                    InitalCantity = 100
                },
            };

            foreach (var inventory in inventories)
            {
                context.Inventory.Add(inventory);
                context.SaveChanges();
            }
        }
Exemplo n.º 4
0
        private void SeedPromotion(BreadingBreadDbContext context)
        {
            var promotions = new Promotion[]
            {
                new Promotion
                {
                    IdProducto     = 1,
                    CantitySaleMin = 10,
                    CantityFree    = 1,
                    Active         = true
                },
                new Promotion
                {
                    IdProducto     = 2,
                    CantitySaleMin = 10,
                    CantityFree    = 1,
                    Active         = false
                },
                new Promotion
                {
                    IdProducto     = 3,
                    CantitySaleMin = 10,
                    Discount       = 10,
                    Active         = true
                },
                new Promotion
                {
                    IdProducto = 4,
                    SaleMin    = 300,
                    Discount   = 10,
                    Active     = true
                },
                new Promotion
                {
                    IdProducto  = 5,
                    SaleMin     = 300,
                    CantityFree = 2,
                    Active      = true
                },
            };

            foreach (var promotion in promotions)
            {
                context.Promotion.Add(promotion);
                context.SaveChanges();
            }
        }
Exemplo n.º 5
0
        private void SeedUsuario(BreadingBreadDbContext db)
        {
            var usuarios = new User[]
            {
                new User
                {
                    // Id = 1,
                    UserName          = "******",
                    UserType          = Domain.Enums.UserType.Admin,
                    HashedPassword    = "******",
                    Aproved           = true,
                    TokenConfirmacion = "",
                    Name = "Nombre APaterno AMaterno Completo",
                    NormalizedUserName = "******"
                },
                new User
                {
                    // Id = 2,
                    UserName          = "******",
                    UserType          = Domain.Enums.UserType.User,
                    HashedPassword    = "******",
                    Aproved           = true,
                    TokenConfirmacion = "",
                    Name = "Nombre",
                    NormalizedUserName = "******"
                },
                new User
                {
                    UserName          = "******",
                    UserType          = Domain.Enums.UserType.User,
                    HashedPassword    = "******",
                    Aproved           = false,
                    TokenConfirmacion = "",
                    Name = "Usuario2 ",
                    NormalizedUserName = "******"
                },
            };

            foreach (var usuario in usuarios)
            {
                db.User.Add(usuario);
                db.SaveChanges();
            }
        }
Exemplo n.º 6
0
        public void SeedEverything(BreadingBreadDbContext context)
        {
            context.Database.EnsureCreated();

            if (context.User.Any())
            {
                return; // Db has been seeded
            }
            SeedUsuario(context);
            SeedPaths(context);
            SeedStores(context);
            SeedProducts(context);
            SeedInventory(context);
            SeedPromotion(context);
            SeedPathStore(context);
            SeedUserSale(context);
            SeedSale(context);
            SeedSaleProduct(context);
        }
Exemplo n.º 7
0
        private void SeedStores(BreadingBreadDbContext context)
        {
            var stores = new Store[]
            {
                new Store
                {
                    Name = "La Esquinita",
                },
                new Store
                {
                    Name = "El atoron",
                },
                new Store
                {
                    Name = "La tienda de don juan",
                },
                new Store
                {
                    Name = "Don pancho",
                },
                new Store
                {
                    Name = "Abuelito del Lson ",
                },
                new Store
                {
                    Name = "Nieves la Miguel",
                },
                new Store
                {
                    Name = "El cerro (casa de termy)",
                },
            };

            foreach (var store in stores)
            {
                context.Store.Add(store);
                context.SaveChanges();
            }
        }
Exemplo n.º 8
0
        private void SeedPaths(BreadingBreadDbContext context)
        {
            var paths = new Path[]
            {
                new Path
                {
                    Name = "Ruta 1",
                },
                new Path
                {
                    Name = "Ruta 2",
                },
                new Path
                {
                    Name = "Ruta 3",
                },
                new Path
                {
                    Name = "Ruta 4",
                },
                new Path
                {
                    Name = "Ruta 5",
                },
                new Path
                {
                    Name = "Ruta 6",
                },
            };

            foreach (var path in paths)
            {
                context.Path.Add(path);
                context.SaveChanges();
            }
        }
Exemplo n.º 9
0
        private void SeedSaleProduct(BreadingBreadDbContext context)
        {
            var productSale = new ProductSale[]
            {
                new ProductSale
                {
                    IdSale    = 1,
                    IdProduct = 1,
                    Cantity   = 10,
                    UnitPrice = 3,
                    Total     = 30
                },
                new ProductSale
                {
                    IdSale    = 1,
                    IdProduct = 2,
                    Cantity   = 2,
                    UnitPrice = 10,
                    Total     = 20,
                },
                new ProductSale
                {
                    IdSale        = 1,
                    IdProduct     = 3,
                    Cantity       = 10,
                    UnitPrice     = 10,
                    Total         = 30,
                    IdPromo       = 1,
                    ReturnCantity = 2
                },
                new ProductSale
                {
                    IdSale    = 1,
                    IdProduct = 1,
                    Cantity   = 10,
                    UnitPrice = 3,
                    Total     = 9.9M,
                    IdPromo   = 2,
                    Discount  = 20.1M,
                },
                new ProductSale
                {
                    IdSale    = 2,
                    IdProduct = 1,
                    Cantity   = 10,
                    UnitPrice = 3,
                    Total     = 30
                },
                new ProductSale
                {
                    IdSale    = 3,
                    IdProduct = 1,
                    Cantity   = 10,
                    UnitPrice = 3,
                    Total     = 30
                },
            };

            foreach (var sale in productSale)
            {
                context.ProductSale.Add(sale);
                context.SaveChanges();
            }
        }
Exemplo n.º 10
0
        public static void Initialize(BreadingBreadDbContext context)
        {
            var initializer = new BreadingBreadDbInitializer();

            initializer.SeedEverything(context);
        }
Exemplo n.º 11
0
        private void SeedProducts(BreadingBreadDbContext context)
        {
            var products = new Product[]
            {
                new Product
                {
                    Name  = "Baguette",
                    Price = 8
                },
                new Product
                {
                    Name  = "Bolillo Ch.",
                    Price = 6
                },
                new Product
                {
                    Name  = "Cuerno",
                    Price = 7
                },
                new Product
                {
                    Name  = "Marihuano",
                    Price = (decimal)10.5
                },
                new Product
                {
                    Name  = "Pellizco",
                    Price = (decimal)9.5
                },
                new Product
                {
                    Name  = "Bolillo Gr.",
                    Price = 15
                },
                new Product
                {
                    Name  = "Dona",
                    Price = 8
                },
                new Product
                {
                    Name  = "Pan grande bolillo mamalon",
                    Price = 15
                },
                new Product
                {
                    Name  = "Concha",
                    Price = 6
                },
                new Product
                {
                    Name  = "Gollete",
                    Price = 10
                },
                new Product
                {
                    Name  = "Panquesito",
                    Price = 7
                },
            };

            foreach (var product in products)
            {
                context.Product.Add(product);
                context.SaveChanges();
            }
        }
Exemplo n.º 12
0
        private void SeedSale(BreadingBreadDbContext context)
        {
            var sales = new Sale[]
            {
                new Sale
                {
                    IdUserSale = 1,
                    IdStore    = 1,
                    Total      = 20,
                    Visited    = System.DateTime.Now,
                    Lat        = 1.1223,
                    Lon        = -1223.22,
                    Commentary = ""
                },
                new Sale
                {
                    IdUserSale = 1,
                    IdStore    = 2,
                    Total      = 30,
                    Visited    = System.DateTime.Now,
                    Lat        = 1.1223,
                    Lon        = -1223.22,
                    Commentary = ""
                },
                new Sale
                {
                    IdUserSale = 1,
                    IdStore    = 3,
                    Total      = 30,
                    Visited    = System.DateTime.Now,
                    Lat        = 1.1223,
                    Lon        = -1223.22,
                    Commentary = ""
                },
                new Sale
                {
                    IdUserSale = 2,
                    IdStore    = 1,
                    Total      = 20,
                    Visited    = System.DateTime.Now.AddDays(-1),
                    Lat        = 1.1223,
                    Lon        = -1223.22,
                    Commentary = ""
                },
                new Sale
                {
                    IdUserSale = 3,
                    IdStore    = 2,
                    Total      = 20,
                    Visited    = System.DateTime.Now.AddDays(-1),
                    Lat        = 1.1223,
                    Lon        = -1223.22,
                    Commentary = ""
                },
            };

            foreach (var sale in sales)
            {
                context.Sale.Add(sale);
                context.SaveChanges();
            }
        }