コード例 #1
0
        public static void AgregarData(IApplicationBuilder ab)
        {
            AppDbContext contexto = ab.ApplicationServices.GetRequiredService <AppDbContext>();

            if (!contexto.CategoriasProductos.Any())
            {
                //CategoriasProductosIniciales es una coleccion local
                contexto.CategoriasProductos.AddRange(CategoriasProductosIniciales.Select(c => c.Value));
            }
            if (!contexto.Productos.Any())
            {
                contexto.AddRange
                (
                    new Productos {
                    NombreProducto = "Huawei p20 Pro", DescripProducto = "Telefono Androi Alta Gama", PreCostoProducto = 600.0M, PreVentaProducto = 750.0M, ImagenURL = "/Imagenes/productos/HUAWEIP20.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Telefonos"]
                },
                    new Productos {
                    NombreProducto = "Laptop HP", DescripProducto = "Computadora portil", PreCostoProducto = 600.0M, PreVentaProducto = 850.0M, ImagenURL = "/Imagenes/productos/LAPTOPHP.jpg", ProductoEnOferta = false, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Computadoras"]
                },
                    new Productos {
                    NombreProducto = "PlayStation PRO", DescripProducto = "Cosola de videojuegos", PreCostoProducto = 350.0M, PreVentaProducto = 500.0M, ImagenURL = "/Imagenes/productos/PSPRO.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Consolas"]
                },
                    new Productos {
                    NombreProducto = "LG 4K", DescripProducto = "Television LG 49 pulgadas", PreCostoProducto = 400.0M, PreVentaProducto = 900.0M, ImagenURL = "/Imagenes/productos/LG.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["TV"]
                },
                    new Productos {
                    NombreProducto = "Sillón Reclinable", DescripProducto = "Sillón individual reclinable mecedora negro", PreCostoProducto = 90.0M, PreVentaProducto = 299.0M, ImagenURL = "/Imagenes/productos/MUEBLE.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Muebles"]
                },
                    new Productos {
                    NombreProducto = "Batidora Pajarito", DescripProducto = "Batidora Mini Artisan 3.5 litros", PreCostoProducto = 100.0M, PreVentaProducto = 339.9M, ImagenURL = "/Imagenes/productos/BATIDORA.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Electrodomesticos"]
                },
                    new Productos {
                    NombreProducto = "Microondas Panasonic", DescripProducto = "Microondas 2.2 pies de 1200w ", PreCostoProducto = 100.0M, PreVentaProducto = 219.0M, ImagenURL = "/Imagenes/productos/MICROONDAS.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Electrodomesticos"]
                },
                    new Productos {
                    NombreProducto = "Cafetera Oster", DescripProducto = "Cafetera 4 tazas", PreCostoProducto = 25.0M, PreVentaProducto = 34.90M, ImagenURL = "/Imagenes/productos/MICROONDAS.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Electrodomesticos"]
                },
                    new Productos {
                    NombreProducto = "Comedor", DescripProducto = "Comedor 6 personas rectangular", PreCostoProducto = 319.0M, PreVentaProducto = 631.99M, ImagenURL = "/Imagenes/productos/COMEDOR.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Muebles"]
                },
                    new Productos {
                    NombreProducto = "Cama King Koil", DescripProducto = "Cama matrimonial edición especial", PreCostoProducto = 100.0M, PreVentaProducto = 260.0M, ImagenURL = "/Imagenes/productos/MUEBLE.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Muebles"]
                }
                );
            }

            contexto.SaveChanges();
        }//fin de agregarData
コード例 #2
0
ファイル: DataInicio.cs プロジェクト: edgardo123/Pos_farmacia
        public static void AgregarData(IApplicationBuilder ab)
        {
            AppDBContext contexto = ab.ApplicationServices.GetRequiredService <AppDBContext>();

            if (!contexto.CiudadCliente.Any())
            {
                //CategoriasProductosIniciales es una coleccion local
                contexto.CiudadCliente.AddRange(CategoriasProductosIniciales.Select(c => c.Value));
            }
            if (!contexto.Clientes.Any())
            {
                contexto.AddRange
                (
                    new Productos {
                    NombreProducto = "Raspberry Pi 2", DescripCortaProducto = "Tableta de Entrenamiento Raspberry Pi Model B", DescripLargaProducto = "512 MB, Procesador ARM, Ethernet, HDMI, 4 USB 2.0", PreCostoProducto = 20.0M, PreVentaProducto = 35.0M, ImagenURL = "/Imagenes/productos/raspberry2.jpg", ImagenPreviaURL = "/Imagenes/productos/sraspberry2.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Tabletas de Entrenamiento"]
                },
                    new Productos {
                    NombreProducto = "Raspberry Pi 3", DescripCortaProducto = "Tableta de Entrenamiento Raspberry Pi Model B+", DescripLargaProducto = "1 GB, Procesador ARM Cortex, Ethernet, HDMI, 4 USB 3.0", PreCostoProducto = 25.0M, PreVentaProducto = 40.0M, ImagenURL = "/Imagenes/productos/raspberry3.jpg", ImagenPreviaURL = "/Imagenes/productos/sraspberry3.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Tabletas de Entrenamiento"]
                },
                    new Productos {
                    NombreProducto = "Raspberry Pi Zero", DescripCortaProducto = "Tableta de Entrenamiento Raspberry Pi Zero", DescripLargaProducto = "512 MB, Procesador ARM Cortex, HDMI, 1 USB 3.0", PreCostoProducto = 15.0M, PreVentaProducto = 22.0M, ImagenURL = "/Imagenes/productos/raspberryzero.jpg", ImagenPreviaURL = "/Imagenes/productos/sraspberryzero.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Tabletas de Entrenamiento"]
                },
                    new Productos {
                    NombreProducto = "Office 2016 Standard", DescripCortaProducto = "Microsoft Office 2016 Standard", DescripLargaProducto = "Word, Excel, PowerPoint, Outlook", PreCostoProducto = 16.0M, PreVentaProducto = 25.0M, ImagenURL = "/Imagenes/productos/office.jpg", ImagenPreviaURL = "/Imagenes/productos/soffice.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Software"]
                },
                    new Productos {
                    NombreProducto = "Office 2016 Professional", DescripCortaProducto = "Microsoft Office 2016 Professional", DescripLargaProducto = "Word, Excel, PowerPoint, Outlook, Access", PreCostoProducto = 25.0M, PreVentaProducto = 35.0M, ImagenURL = "/Imagenes/productos/office2.jpg", ImagenPreviaURL = "/Imagenes/productos/soffice2.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Software"]
                },
                    new Productos {
                    NombreProducto = "Multimetro", DescripCortaProducto = "Tester con baterias AC", DescripLargaProducto = "Multimetro Digital con baterias AC", PreCostoProducto = 30.0M, PreVentaProducto = 50.0M, ImagenURL = "/Imagenes/productos/tester1.jpg", ImagenPreviaURL = "/Imagenes/productos/stester1.jpg", ProductoEnOferta = true, ProductoEnExistencia = true, EstadoProducto = true, CatProductos = CategoriasProductosIniciales["Insumos de Electronica"]
                }
                );
            }

            contexto.SaveChanges();
        }//fin de agregarData