예제 #1
0
        public double ObtenerReputacionComprador(String tenant, int usuarioId)
        {
            IDALSubasta    _dalSub  = new DALSubastaEF();
            List <Subasta> compras  = _dalSub.ObtenerComprasbyUsuario(tenant, usuarioId);
            int            total    = 0;
            int            cantidad = 0;

            foreach (var item in compras)
            {
                var calificacion = _dal.ObtenerCalificacionDelVendedor(tenant, item.id);
                if (calificacion != null)
                {
                    total = total + calificacion.puntaje;
                    cantidad++;
                }
            }

            if (total == 0)
            {
                return(0);
            }
            else
            {
                return(total / cantidad);
            }
        }
예제 #2
0
        //URL: api/subasta?searchTerm=terminosdebusqueda;
        public Subasta[] Get(string searchTerm)
        {
            IDALSubasta         ip  = new DALSubastaEF();
            List <DataProducto> ldp = ip.ObtenerProductosBuscados(searchTerm, "MobileCenter");

            Subasta[] ret = new Subasta[ldp.Count];
            int       i   = 0;

            Debug.WriteLine("A");
            foreach (DataProducto dp in ldp)
            {
                Subasta s = new Subasta
                {
                    Descripcion = dp.descripcion,
                    ProductoID  = dp.ProductoID,
                    //fecha_cierre = dp.fecha_cierre,
                    IDOfertante  = dp.idOfertante,
                    Nombre       = dp.nombre,
                    PrecioActual = dp.precio_actual
                };
                ret[i] = s;
                i++;
                Debug.WriteLine("b");
            }
            return(ret);
        }
예제 #3
0
        //URL: http://chebayrest1930.azurewebsites.net/api/subasta
        public Subasta[] Get()
        {
            IDALSubasta         ip  = new DALSubastaEF();
            List <DataProducto> ldp = ip.ObtenerProductosPersonalizados("MobileCenter");

            //DataProducto dp = ldp.FirstOrDefault();
            Subasta[] ret = new Subasta[ldp.Count];
            int       i   = 0;

            foreach (DataProducto dp in ldp)
            {
                Debug.WriteLine("GET");
                Subasta s = new Subasta
                {
                    Descripcion = dp.descripcion,
                    ProductoID  = dp.ProductoID,
                    //fecha_cierre = dp.fecha_cierre,
                    IDOfertante  = dp.idOfertante,
                    Nombre       = dp.nombre,
                    PrecioActual = dp.precio_actual
                };
                ret[i] = s;
                i++;
            }
            return(ret);
        }
예제 #4
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.");
      }
예제 #5
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.");
      }
예제 #6
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.");
      }
예제 #7
0
        //URL: http://chebayrest1930.azurewebsites.net/api/subasta?idProducto=
        public Subasta[] Get(string idProducto)
        {
            IDALSubasta ip     = new DALSubastaEF();
            int         idProd = Int32.Parse(idProducto);
            Producto    p      = ip.ObtenerProducto(idProd, "MobileCenter");

            Subasta[] ret = new Subasta[1];

            Subasta s = new Subasta
            {
                Descripcion = p.descripcion,
                ProductoID  = p.ProductoID,

                Nombre       = p.nombre,
                PrecioActual = p.precio_base_subasta;
            };

            ret[0] = s;
            return(ret);
        }
예제 #8
0
 //URL: api/subasta?monto=xx&idProducto=xx&idUsuario=xx&idTienda=xx;
 public string Get(int monto, long idProducto, string idUsuario)
 {
     try
     {
         IDALSubasta ip = new DALSubastaEF();
         Oferta      o  = new Oferta
         {
             monto      = monto,
             ProductoID = idProducto,
             UsuarioID  = idUsuario
         };
         ip.OfertarProducto(o, "MobileCenter");
         return("Oferta realizada correctamente.");
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         Console.WriteLine(e.Message);
         throw;
     }
 }
예제 #9
0
        public void Run(string tiendaID)
        {
            IDALUsuario udal = new DALUsuarioEF();
            IDALTienda  tdal = new DALTiendaEF();
            IDALSubasta sdat = new DALSubastaEF();

            Tienda          tienda    = tdal.ObtenerTienda(tiendaID);
            List <Producto> productos = sdat.ObtenerTodosProductos(tienda.TiendaID);
            //obtengo algoritmo
            Personalizacion pers             = tdal.ObtenerPersonalizacionTienda(tienda.TiendaID);
            List <Usuario>  usuarios         = udal.ObtenerTodosUsuariosFull(tienda.TiendaID);
            bool            defaultalgorithm = false;

            if (pers.algoritmo == null || pers.algoritmo.Length == 0)
            {
                defaultalgorithm = true;
            }

            //creo indice
            Task index = udal.InicializarColeccionRecomendaciones(tienda.TiendaID);

            index.Wait();

            foreach (var user in usuarios)
            {
                if (defaultalgorithm)
                {
                    Algorithms def = new Algorithms();
                    def.default_recomendation_algorithm(productos, user, tienda.TiendaID);
                }
                else
                {
                    Algorithms a = new Algorithms();
                    a.custom_algorithm(pers, productos, user, tienda.TiendaID);
                }
            }//IF tienda es de instancia...
        }
예제 #10
0
        private void procesarSubasta(DataProductoQueue p)
        {
            IDALSubasta      ip  = new DALSubastaEF();
            BLNotificaciones bl  = new BLNotificaciones();
            IDALUsuario      ubl = new DALUsuarioEF();

            //obtengo producto
            Producto prod = ip.ObtenerProducto(p.ProductoID, p.TiendaID);

            //Si no fue comprado por CompraDirecta
            if (!ip.ExisteCompra(p.ProductoID, p.TiendaID))
            {
                //vendedor
                Usuario vendedor = ubl.ObtenerUsuario(p.OwnerProducto, p.TiendaID);

                if (ip.TieneOfertas(p.ProductoID, p.TiendaID))
                {
                    //Obtengo la oferta ganadora.
                    Oferta o = ip.ObtenerOfertaGanadora(p.ProductoID, p.TiendaID);

                    //Creo una compra entre el Producto y el Usuario.
                    Compra c = new Compra
                    {
                        fecha_compra = p.fecha_cierre,
                        monto        = o.monto,
                        ProductoID   = o.ProductoID,
                        UsuarioID    = o.UsuarioID
                    };
                    //se envia mensaje al vendedor en AgregarCompra
                    ip.AgregarCompraPostSubasta(c, p.TiendaID);

                    //obtengo mail ganador
                    Usuario u = ubl.ObtenerUsuario(c.UsuarioID, p.TiendaID);
                    //Notifico al ganador.
                    String linkTienda  = "http://chebuynow.azurewebsites.net/" + p.TiendaID;
                    String linkCalif   = "http://chebuynow.azurewebsites.net/" + p.TiendaID + "/Usuario/CalificarUsuario?prodId=" + p.ProductoID;
                    string bodyMensaje = getBodyMailHTML(p.TiendaID + ": Subasta ganada!", "Has ganado una nueva subasta!", u, prod, c.monto, true, linkCalif, linkTienda);

                    string asunto = "Chebay: Subasta de producto!";
                    bl.sendEmailNotification(u.Email, asunto, bodyMensaje);


                    //en agregar compra se notifica al vendedor.

                    //mail a vendedor
                    //obtengo vendedor
                    IDALUsuario udal = new DALUsuarioEF();

                    string asuntovendedor      = "Chebay: Venta de producto!";
                    string bodyMensajeVendedor = getBodyMailHTML(p.TiendaID + ": Producto vendido!", "Has vendido un nuevo producto!", vendedor, prod, c.monto, false, "", linkTienda);

                    if (vendedor.Email != null)
                    {
                        bl.sendEmailNotification(vendedor.Email, asuntovendedor, bodyMensajeVendedor);
                    }
                    else
                    {
                        if (IsValidMail(vendedor.UsuarioID))
                        {
                            bl.sendEmailNotification(vendedor.UsuarioID, asuntovendedor, bodyMensajeVendedor);
                        }
                        //else... por algun error no tiene mail
                    }
                }
                else
                {
                    //no fue comprado
                    Debug.WriteLine("NO TIENE COMPRAS MAIL AL VENDEDOR");
                    String linkTienda          = "http://chebuynow.azurewebsites.net/" + p.TiendaID;
                    string asunto              = "Chebay: Producto no vendido...";
                    string bodyMensajeVendedor = getBodyMailHTML(p.TiendaID + ": Producto no vendido...", "No se ha logrado subastar su producto.", vendedor, prod, 0, false, "", linkTienda);
                    bl.sendEmailNotification(vendedor.Email, asunto, bodyMensajeVendedor);
                }
            }//si fue comprado se descarta el mensaje.
        }
예제 #11
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");
        }