예제 #1
0
        public void importMobileCenterProducts()
        {
            DALMercadoLibreREST ml = new DALMercadoLibreREST();
            string tenant_name     = "MobileCenter";

            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3518", 5);  //samsung MLU3518
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU32089", 4); //apple iphone MLU32089
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU7076", 8);  //lg MLU7076
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3514", 9);  //sony MLU3514
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3506", 6);  //nokia
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3502", 7);  //motorola
        }
예제 #2
0
        public void SeedMobileCenter()
        {
            Usuario[] users =
            {
                new Usuario {
                    UsuarioID = "*****@*****.**", Email = "*****@*****.**", Nombre = "Dexter", fecha_ingreso = DateTime.UtcNow
                },
                new Usuario {
                    UsuarioID = "*****@*****.**", Email = "*****@*****.**", Nombre = "Newton", fecha_ingreso = DateTime.UtcNow
                },
                new Usuario {
                    UsuarioID = "*****@*****.**", Email = "*****@*****.**", Nombre = "Cantor", fecha_ingreso = DateTime.UtcNow
                },
                new Usuario {
                    UsuarioID = "*****@*****.**", Email = "*****@*****.**", Nombre = "Arquimedes", fecha_ingreso = DateTime.UtcNow
                },
                new Usuario {
                    UsuarioID = "*****@*****.**", Email = "*****@*****.**", Nombre = "Gauss", fecha_ingreso = DateTime.UtcNow
                },
                new Usuario {
                    UsuarioID = "*****@*****.**", Email = "*****@*****.**", Nombre = "Euler", fecha_ingreso = DateTime.UtcNow
                }
            };
            foreach (var u in users)
            {
                usuarios.Add(u);
            }
            SaveChanges();

            CategoriaCompuesta[] catscom =
            {
                new CategoriaCompuesta {
                    CategoriaID = 1, Nombre = "Raiz", padre = null
                },
            };
            Categoria[] catssim =
            {
                new CategoriaSimple {
                    CategoriaID = 2, Nombre = "Samsung", padre = catscom[0]
                },
                new CategoriaSimple {
                    CategoriaID = 3, Nombre = "Apple", padre = catscom[0]
                },
                new CategoriaSimple {
                    CategoriaID = 4, Nombre = "LG", padre = catscom[0]
                },
                new CategoriaSimple {
                    CategoriaID = 5, Nombre = "Sony", padre = catscom[0]
                },
                new CategoriaSimple {
                    CategoriaID = 6, Nombre = "Motorola", padre = catscom[0]
                }
            };
            foreach (var c in catscom)
            {
                categorias.Add(c);
            }
            SaveChanges();

            foreach (var c in catssim)
            {
                categorias.Add(c);
            }
            SaveChanges();


            TipoAtributo[] tatrs =
            {
                new TipoAtributo {
                    TipoAtributoID = "CamaraRes", tipodato = TipoDato.INTEGER
                },
                new TipoAtributo {
                    TipoAtributoID = "Pantalla", tipodato = TipoDato.INTEGER
                },
                new TipoAtributo {
                    TipoAtributoID = "FechaRelease", tipodato = TipoDato.STRING
                },
                new TipoAtributo {
                    TipoAtributoID = "Storage", tipodato = TipoDato.INTEGER
                }
            };

            foreach (var a in tatrs)
            {
                a.categorias = new List <Categoria>();
                a.categorias.Add(categorias.Find(2)); //agrego a categoria samsung
                tipoatributos.Add(a);
            }

            SaveChanges();

            //Samsung sample
            Atributo[] atrs =
            {
                new Atributo {
                    etiqueta = "CamaraRes", valor = "X82", TipoAtributoID = "CamaraRes"
                },
                new Atributo {
                    etiqueta = "Screen Size", valor = "5", TipoAtributoID = "Pantalla"
                },
                new Atributo {
                    etiqueta = "InternaMemory", valor = "16", TipoAtributoID = "Storage"
                },
                new Atributo {
                    etiqueta = "Camera resolution", valor = "13", TipoAtributoID = "CamaraRes"
                },
                new Atributo {
                    etiqueta = "InternaMemory", valor = "64", TipoAtributoID = "Storage"
                }
            };

            foreach (var a in atrs)
            {
                atributos.Add(a);
            }
            SaveChanges();

            Producto[] products =
            {
                new Producto {
                    UsuarioID = "*****@*****.**", CategoriaID = 2, nombre = "Samsung S6", descripcion = "bestia", fecha_cierre = DateTime.UtcNow
                },
                new Producto {
                    UsuarioID = "*****@*****.**", CategoriaID = 2, nombre = "Samsung S5", descripcion = "bestia", fecha_cierre = DateTime.UtcNow
                }
            };
            foreach (var p in products)
            {
                p.atributos = new List <Atributo>();
                var atrib = from a in atributos
                            where a.AtributoID == 1
                            select a;
                p.atributos.Add(atrib.First());
                productos.Add(p);
            }

            SaveChanges();

            //* Cargo productos con webscraping*//
            IDALMercadoLibreREST ml = new DALMercadoLibreREST();

            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3518", 2);  //samsung MLU3518
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU32089", 3); //apple iphone MLU32089
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU7076", 4);  //lg MLU7076
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3514", 5);  //sony MLU3514
            //nokia MLU3506

            System.Console.WriteLine("Lista de Usuarios:");
            foreach (var u in usuarios)
            {
                System.Console.WriteLine(u.UsuarioID);
            }

            System.Console.WriteLine("Lista de Productos");
            foreach (var p in productos)
            {
                System.Console.WriteLine(p.ProductoID + " " + " " + p.nombre + "" + p.descripcion + " " + p.UsuarioID);
            }

            System.Console.WriteLine("Lista de Categorias");
            foreach (var c in categorias)
            {
                System.Console.WriteLine(c.CategoriaID + " " + c.Nombre);
            }

            System.Console.WriteLine("Lista de Atributos");
            foreach (var a in atributos)
            {
                System.Console.WriteLine(a.AtributoID + " " + a.etiqueta + " " + a.valor);
            }
        }
예제 #3
0
        public void SeedMobileCenter()
        {
            Usuario[] users = {
                                new Usuario{ UsuarioID="*****@*****.**", Email="*****@*****.**" ,Nombre="Dexter", fecha_ingreso= DateTime.UtcNow},
                                new Usuario{ UsuarioID="*****@*****.**", Email="*****@*****.**", Nombre="Newton", fecha_ingreso= DateTime.UtcNow },
                                new Usuario{ UsuarioID="*****@*****.**", Email="*****@*****.**", Nombre="Cantor" , fecha_ingreso= DateTime.UtcNow},
                                new Usuario{ UsuarioID="*****@*****.**", Email="*****@*****.**", Nombre="Arquimedes", fecha_ingreso= DateTime.UtcNow},
                                new Usuario{ UsuarioID="*****@*****.**", Email="*****@*****.**", Nombre="Gauss", fecha_ingreso= DateTime.UtcNow},
                                new Usuario{ UsuarioID="*****@*****.**", Email="*****@*****.**", Nombre="Euler", fecha_ingreso= DateTime.UtcNow}
                              };
            foreach (var u in users)
            {
                usuarios.Add(u);
            }
            SaveChanges();

            CategoriaCompuesta[] catscom = {
                                    new CategoriaCompuesta { CategoriaID=1, Nombre = "Raiz", padre=null},
                                  };
            Categoria[] catssim = {
                                    new CategoriaSimple { CategoriaID=2, Nombre = "Samsung", padre= catscom[0] },
                                    new CategoriaSimple { CategoriaID=3, Nombre = "Apple", padre= catscom[0]},
                                    new CategoriaSimple { CategoriaID=4, Nombre = "LG", padre= catscom[0]},
                                    new CategoriaSimple { CategoriaID=5, Nombre = "Sony", padre= catscom[0]},
                                    new CategoriaSimple { CategoriaID=6, Nombre = "Motorola", padre= catscom[0]}
                                  };
            foreach (var c in catscom)
            {
                categorias.Add(c);
            }
            SaveChanges();

            foreach (var c in catssim)
            {
                categorias.Add(c);
            }
            SaveChanges();

            TipoAtributo[] tatrs = {
                                     new TipoAtributo{TipoAtributoID="CamaraRes", tipodato=TipoDato.INTEGER},
                                     new TipoAtributo{TipoAtributoID="Pantalla", tipodato=TipoDato.INTEGER},
                                     new TipoAtributo{TipoAtributoID="FechaRelease", tipodato=TipoDato.STRING},
                                     new TipoAtributo{TipoAtributoID="Storage", tipodato=TipoDato.INTEGER}
                                   };

            foreach (var a in tatrs)
            {
                a.categorias = new List<Categoria>();
                a.categorias.Add(categorias.Find(2)); //agrego a categoria samsung
                tipoatributos.Add(a);
            }

            SaveChanges();

            //Samsung sample
            Atributo[] atrs = {
                                new Atributo{ etiqueta="CamaraRes", valor="X82", TipoAtributoID="CamaraRes" },
                                new Atributo{ etiqueta="Screen Size", valor="5", TipoAtributoID="Pantalla" },
                                new Atributo{ etiqueta="InternaMemory", valor="16", TipoAtributoID="Storage" },
                                new Atributo{ etiqueta= "Camera resolution", valor="13", TipoAtributoID="CamaraRes" },
                                new Atributo{ etiqueta="InternaMemory", valor="64", TipoAtributoID="Storage" }
                              };

            foreach (var a in atrs)
            {
                atributos.Add(a);
            }
            SaveChanges();

            Producto[] products = {
                                    new Producto{ UsuarioID="*****@*****.**", CategoriaID=2, nombre="Samsung S6", descripcion="bestia", fecha_cierre= DateTime.UtcNow },
                                    new Producto{ UsuarioID="*****@*****.**", CategoriaID=2, nombre="Samsung S5", descripcion="bestia", fecha_cierre= DateTime.UtcNow }
                                  };
            foreach (var p in products)
            {
                p.atributos = new List<Atributo>();
                var atrib = from a in atributos
                            where a.AtributoID == 1
                            select a;
                p.atributos.Add(atrib.First());
                productos.Add(p);
            }

            SaveChanges();

            //* Cargo productos con webscraping*//
            IDALMercadoLibreREST ml = new DALMercadoLibreREST();
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3518", 2); //samsung MLU3518
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU32089", 3); //apple iphone MLU32089
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU7076", 4); //lg MLU7076
            ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3514", 5); //sony MLU3514
            //nokia MLU3506

            System.Console.WriteLine("Lista de Usuarios:");
            foreach (var u in usuarios)
            {
                System.Console.WriteLine(u.UsuarioID);
            }

            System.Console.WriteLine("Lista de Productos");
            foreach (var p in productos)
            {
                System.Console.WriteLine(p.ProductoID + " "  + " " + p.nombre + "" + p.descripcion + " " + p.UsuarioID );
            }

            System.Console.WriteLine("Lista de Categorias");
            foreach(var c in categorias){
                System.Console.WriteLine(c.CategoriaID + " " + c.Nombre);
            }

            System.Console.WriteLine("Lista de Atributos");
            foreach (var a in atributos)
            {
                System.Console.WriteLine(a.AtributoID + " " + a.etiqueta + " " + a.valor);
            }
        }
예제 #4
0
 public void importMobileCenterProducts()
 {
     DALMercadoLibreREST ml = new DALMercadoLibreREST();
     string tenant_name = "MobileCenter";
     ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3518", 5); //samsung MLU3518
     ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU32089", 4); //apple iphone MLU32089
     ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU7076", 8); //lg MLU7076
     ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3514", 9); //sony MLU3514
     ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3506", 6); //nokia
     ml.ObtenerProductosMLporCategoria(tenant_name, "10", "MLU3502", 7);//motorola
 }