Exemplo n.º 1
0
      public void CierreSubastaNoCompras()
      {
          Console.WriteLine("Cierre subasta sin compradores");
          IDALSubasta sdal = new DALSubastaEF();
          Producto    p    = new Producto {
              nombre = "test", UsuarioID = "*****@*****.**", fecha_cierre = DateTime.UtcNow.AddMinutes(1), CategoriaID = 5
          };

          sdal.AgregarProducto(p, "MobileCenter");
          Console.WriteLine("Se espera que se le notifique al vendedor que no fue exitosa la venta.");
      }
Exemplo n.º 2
0
      public void CierreSubastaCompraDirecta()
      {
          Console.WriteLine("Cierre subasta con compra directa");
          string      tienda = "MobileCenter";
          IDALSubasta sdal   = new DALSubastaEF();
          Producto    p      = new Producto {
              nombre = "test2", UsuarioID = "*****@*****.**", fecha_cierre = DateTime.UtcNow.AddMinutes(1), CategoriaID = 5
          };
          long   prod   = sdal.AgregarProducto(p, tienda);
          Compra compra = new Compra {
              monto = 200, ProductoID = prod, UsuarioID = "*****@*****.**", fecha_compra = DateTime.UtcNow
          };

          sdal.AgregarCompra(compra, tienda);
          Console.WriteLine("Se espera el envio de un mail al vendedor como comprador.");
      }
Exemplo n.º 3
0
      public void CierreSubastaConOferta()
      {
          Console.WriteLine("Cierre subasta con una oferta");
          string      tienda = "MobileCenter";
          IDALSubasta sdal   = new DALSubastaEF();
          Producto    p      = new Producto {
              nombre = "test1", UsuarioID = "*****@*****.**", fecha_cierre = DateTime.UtcNow.AddMinutes(1), CategoriaID = 5
          };
          long prod = sdal.AgregarProducto(p, tienda);

          Oferta o = new Oferta {
              monto = 500, ProductoID = prod, UsuarioID = "*****@*****.**"
          };

          sdal.OfertarProducto(o, tienda);
          Console.WriteLine("Se ha creado un producto y ofertado::" + prod);
          Console.WriteLine("Se espera el envio de un mail al vendedor como comprador.");
      }
Exemplo n.º 4
0
        public void ObtenerProductosMLporCategoria(string TiendaID, string limit, string categoryML, long categoryLocal)
        {
            Debug.Write("DALMERCADOLIBRE::OBTENERPRODUCTOSMLPORCATEGORIA");
            IDALSubasta sdal = new DALSubastaEF();

            string user_ml = "*****@*****.**";

            //verifico si usuario existe
            using (var db = ChebayDBContext.CreateTenant(TiendaID))
            {
                var query = from u in db.usuarios
                            where u.UsuarioID == user_ml
                            select u;
                if (query.Count() == 0)
                {
                    CrearUsuarioML(TiendaID);
                }


                List <Producto> productos = new List <Producto>();
                dynamic         json      = ripJson("/sites/MLU/search?limit=" + limit + "&category=" + categoryML);

                int total = 0;
                foreach (var p in json.results)
                {
                    string   nombre       = (string)p.title;
                    int      price        = (int)double.Parse((string)p.price);
                    int      subasta      = price / 2;
                    string   latitud      = (string)p.seller_address.latitude;
                    string   longitud     = (string)p.seller_address.longitude;
                    DateTime fecha_cierre = Convert.ToDateTime((string)p.stop_time);
                    Producto producto     = new Producto
                    {
                        fecha_cierre        = fecha_cierre,
                        latitud             = latitud,
                        longitud            = longitud,
                        nombre              = nombre,
                        precio_compra       = price,
                        precio_base_subasta = subasta,
                        UsuarioID           = user_ml,
                        CategoriaID         = categoryLocal,
                        imagenes            = new List <ImagenProducto>()
                    };
                    long idprod = sdal.AgregarProducto(producto, TiendaID);
                    //agrego producto

                    Debug.WriteLine("Se agrego producto " + nombre);

                    var imagenes = ObtenerImagenesProducto(idprod, (string)p.id);
                    foreach (var im in imagenes)
                    {
                        sdal.AgregarImagenProducto(im, TiendaID);
                    }

                    total++;
                    Debug.WriteLine(producto.nombre + " "
                                    + producto.UsuarioID + " "
                                    + producto.latitud + " "
                                    + producto.longitud + " "
                                    + producto.precio_compra + " "
                                    + producto.CategoriaID
                                    );
                }
                Debug.WriteLine("Total: " + total);
            }
            Debug.WriteLine("DALMERCADOLIBRE::TERMINO WEBSCRAPPING");
        }