Пример #1
0
        public string Login(usuarios data)
        {
            string un       = data.usuario;
            string Password = data.contraseña;

            using (appUEntities1 Obj = new appUEntities1())
            {
                var user = Obj.usuarios.Where(u => u.usuario == un).FirstOrDefault();
                if (user != null)
                {
                    if (GetMD5(Password) == user.contraseña)
                    {
                        //creamos cookie usuarioLogueado
                        HttpCookie cookie = new HttpCookie("LoginID");
                        cookie.Value   = Convert.ToString(user.idUsuario);
                        cookie.Expires = DateTime.Now.AddMinutes(60);
                        Response.Cookies.Add(cookie);

                        return(user.idUsuario.ToString());
                    }
                    else
                    {
                        return("0");
                    }
                }
                else
                {
                    return("-1");
                }
            }
        }
Пример #2
0
        public JsonResult NegocioActual()
        {
            appUEntities1 db    = new appUEntities1();
            bool          proxy = db.Configuration.ProxyCreationEnabled;
            //cookie usuarioLogueado
            int idUsuario = Convert.ToInt32(Request.Cookies["LoginID"].Value);

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                negocios negocio = db.negocios.Where(x => x.fkUsuario == idUsuario).First();

                //creamos cookie idNegocio
                if (Session["negocioId"] == null)
                {
                    Session["negocioId"] = negocio.idNegocio;
                }

                return(Json(negocio, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                db.Configuration.ProxyCreationEnabled = proxy;
            }
        }
Пример #3
0
        /// <summary>
        /// Update negocioe Information
        /// </summary>
        /// <param name="Emp"></param>
        /// <returns></returns>
        public string UpdateNegocio(negocios Neg)
        {
            var    file = Request.Files[0];
            string fileName;

            if (Neg != null)
            {
                fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                file.SaveAs(Path.Combine(Server.MapPath("~/imagenesProductos"), fileName));
                using (appUEntities1 Obj = new appUEntities1())
                {
                    var      Neg_   = Obj.Entry(Neg);
                    negocios negObj = Obj.negocios.Where(x => x.idNegocio == Neg.idNegocio).FirstOrDefault();
                    negObj.nombre              = Neg.nombre;
                    negObj.calle               = Neg.calle;
                    negObj.numero              = Neg.numero;
                    negObj.colonia             = Neg.colonia;
                    negObj.ciudad              = Neg.ciudad;
                    negObj.imgNegocio          = fileName;
                    negObj.permitePagosTarjeta = Neg.permitePagosTarjeta;
                    negObj.precioEnvio         = Neg.precioEnvio;
                    negObj.descripcion         = Neg.descripcion;
                    negObj.correo              = Neg.correo;
                    negObj.codigoPostal        = Neg.codigoPostal;
                    Obj.SaveChanges();
                    return("negocio Updated Successfully");
                }
            }
            else
            {
                return("negocio Not Updated! Try Again");
            }
        }
Пример #4
0
        /// <summary>
        /// Insert New negocioe
        /// </summary>
        /// <param name="negocio"></param>
        /// <returns></returns>
        public string InsertNegocio(negocios negocio)
        {
            var    file = Request.Files[0];
            string fileName;

            if (negocio != null)
            {
                //cookie usuarioLogueado
                int idUsuario = Convert.ToInt32(Request.Cookies["LoginID"].Value);
                fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                file.SaveAs(Path.Combine(Server.MapPath("~/imagenesProductos"), fileName));
                using (appUEntities1 Obj = new appUEntities1())
                {
                    negocio.imgNegocio = fileName;
                    negocio.fkUsuario  = idUsuario;
                    negocio.activo     = true;
                    Obj.negocios.Add(negocio);
                    Obj.SaveChanges();

                    //creamos cookie idNegocio
                    if (Session["negocioId"] == null)
                    {
                        Session["negocioId"] = negocio.idNegocio;
                    }

                    return("negocioe Added Successfully");
                }
            }
            else
            {
                return("negocioe Not Inserted! Try Again");
            }
        }
Пример #5
0
        public string Insert_producto(productos product)
        {
            var    file = Request.Files[0];
            string fileName;

            if (product != null)
            {
                //cookie negocioid
                int idNegocio = Convert.ToInt32(Session["negocioId"]);
                fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                file.SaveAs(Path.Combine(Server.MapPath("~/imagenesProductos"), fileName));
                using (appUEntities1 Obj = new appUEntities1())
                {
                    product.imgProducto   = fileName;
                    product.fkNegocio     = idNegocio;
                    product.fechaRegistro = DateTime.Now;
                    product.fkCategoria   = product.fkCategoria;
                    product.activo        = true;
                    Obj.productos.Add(product);
                    Obj.SaveChanges();
                    return("producto Added Successfully");
                }
            }
            else
            {
                return("producto Not Inserted! Try Again");
            }
        }
Пример #6
0
        /// <summary>
        /// Update negocioe Information
        /// </summary>
        /// <param name="Pro"></param>
        /// <returns></returns>
        public string Update_producto(productos pro)
        {
            var    file = Request.Files[0];
            string fileName;

            if (pro != null)
            {
                fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                file.SaveAs(Path.Combine(Server.MapPath("~/imagenesProductos"), fileName));
                using (appUEntities1 Obj = new appUEntities1())
                {
                    var       Neg_   = Obj.Entry(pro);
                    productos proObj = Obj.productos.Where(x => x.idProducto == pro.idProducto).FirstOrDefault();
                    proObj.imgProducto = fileName;
                    proObj.producto    = pro.producto;
                    proObj.descripcion = pro.descripcion;
                    proObj.precio      = pro.precio;
                    Obj.SaveChanges();
                    return("producto Updated Successfully");
                }
            }
            else
            {
                return("producto Not Updated! Try Again");
            }
        }
Пример #7
0
 /// <summary>
 /// Get negocioe With Id
 /// </summary>
 /// <param name="Id"></param>
 /// <returns></returns>
 public JsonResult Get_negocioById(string Id)
 {
     using (appUEntities1 Obj = new appUEntities1())
     {
         int EmpId = int.Parse(Id);
         return(Json(Obj.negocios.Find(EmpId), JsonRequestBehavior.AllowGet));
     }
 }
Пример #8
0
        public JsonResult traerCantidad(string idPro)
        {
            appUEntities1 db    = new appUEntities1();
            bool          proxy = Obj.Configuration.ProxyCreationEnabled;

            try
            {
                Obj.Configuration.ProxyCreationEnabled = false;
                int     idP   = Convert.ToInt32(idPro);
                decimal total = 0;

                //cookie idventa carrito
                //cookie idventa carrito
                var myCookielog = Request.Cookies["IdVenta"];
                //int idVenta = Convert.ToInt32(Request.Cookies["IdVenta"].Value);

                if (myCookielog == null)
                {
                    var result = new { cantidad = 0, total = total };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }

                int          idVenta = Convert.ToInt32(Request.Cookies["IdVenta"].Value);
                detalleVenta dv      = Obj.detalleVenta.Where(x => x.fkVenta == idVenta && x.fkProducto == idP).FirstOrDefault();
                ventas       venta   = Obj.ventas.Where(z => z.idventa == idVenta).FirstOrDefault();

                total = venta.total;

                if (dv == null)
                {
                    var result = new { cantidad = 0, total = total };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var result = new { cantidad = dv.cantidad, total = total };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                Obj.Configuration.ProxyCreationEnabled = proxy;
            }
        }
Пример #9
0
 /// <summary>
 /// Update negocioe Information
 /// </summary>
 /// <param name="Pro"></param>
 /// <returns></returns>
 public string cambiarEstatusProducto(productos pro)
 {
     if (pro != null)
     {
         using (appUEntities1 Obj = new appUEntities1())
         {
             var       Neg_   = Obj.Entry(pro);
             productos proObj = Obj.productos.Where(x => x.idProducto == pro.idProducto).FirstOrDefault();
             proObj.activo = pro.activo;
             Obj.SaveChanges();
             return("negocioe Updated Successfully");
         }
     }
     else
     {
         return("negocioe Not Updated! Try Again");
     }
 }
Пример #10
0
        public JsonResult traerCategorias()
        {
            appUEntities1 db    = new appUEntities1();
            bool          proxy = db.Configuration.ProxyCreationEnabled;

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                List <categorias> cat = db.categorias.ToList();
                //ViewBag.productos = productos;
                return(Json(cat, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                db.Configuration.ProxyCreationEnabled = proxy;
            }
        }
Пример #11
0
        /// <summary>
        /// Insert New negocioe
        /// </summary>
        /// <param name="usuario"></param>
        /// <returns></returns>
        public string AgregarUsuario(usuarios User)
        {
            if (User != null)
            {
                using (appUEntities1 Obj = new appUEntities1())
                {
                    User.apellidoMaterno = "x";
                    User.contraseña      = GetMD5(User.contraseña);
                    User.fechaRegistro   = DateTime.Now;

                    User.activo = true;
                    Obj.usuarios.Add(User);
                    Obj.SaveChanges();
                    return("1");
                }
            }
            else
            {
                return("-1");
            }
        }
Пример #12
0
        public JsonResult Get_AllNegocios()
        {
            appUEntities1 db    = new appUEntities1();
            bool          proxy = db.Configuration.ProxyCreationEnabled;

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                List <negocios> negocio = db.negocios.Where(x => x.fkUsuario == 1).ToList();

                return(Json(negocio, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                db.Configuration.ProxyCreationEnabled = proxy;
            }
        }
Пример #13
0
 /// <summary>
 /// Delete negocioe Information
 /// </summary>
 /// <param name="Neg"></param>
 /// <returns></returns>
 public string Delete_negocio(negocios Neg)
 {
     if (Neg != null)
     {
         using (appUEntities1 Obj = new appUEntities1())
         {
             var Neg_ = Obj.Entry(Neg);
             if (Neg_.State == System.Data.Entity.EntityState.Detached)
             {
                 Obj.negocios.Attach(Neg);
                 Obj.negocios.Remove(Neg);
             }
             Obj.SaveChanges();
             return("negocioe Deleted Successfully");
         }
     }
     else
     {
         return("negocioe Not Deleted! Try Again");
     }
 }
Пример #14
0
        public JsonResult productoActual(int idP)
        {
            appUEntities1 db    = new appUEntities1();
            bool          proxy = db.Configuration.ProxyCreationEnabled;

            try
            {
                db.Configuration.ProxyCreationEnabled = false;
                productos produc = db.productos.Where(x => x.idProducto == idP).First();

                return(Json(produc, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                db.Configuration.ProxyCreationEnabled = proxy;
            }
        }
Пример #15
0
        public JsonResult PedidosNegocio()
        {
            appUEntities1 db    = new appUEntities1();
            bool          proxy = db.Configuration.ProxyCreationEnabled;

            try
            {
                //cookie negocioid
                int idNegocio = Convert.ToInt32(Session["negocioId"]);

                db.Configuration.ProxyCreationEnabled = false;
                List <ventas> ListVentas = db.ventas.Where(x => x.fkNegocio == idNegocio && x.estatus == 1).ToList();

                return(Json(ListVentas, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.Message));
            }
            finally
            {
                db.Configuration.ProxyCreationEnabled = proxy;
            }
        }