Esempio n. 1
0
        public JsonResult ActualizarDatosCliente()
        {
            bool lStatus;

            DatosClienteDTO _oDatos = new DatosClienteDTO();

            try
            {
                DatosClienteDTO _oCliente = JsonConvert.DeserializeObject <DatosClienteDTO>(Request["oCliente"]);

                _oCliente.iIdCliente = Convert.ToInt32(Session["iIdCliente"]);



                _oDatos = oCliente.ValidarCliente(_oCliente);

                if (_oDatos == null)
                {
                    _oDatos = oCliente.EditarDatos(_oCliente);
                }

                lStatus = true;
            }
            catch (Exception)
            {
                lStatus = false;
            }

            return(Json(new { lStatus, _oDatos }));
        }
Esempio n. 2
0
        /// <summary>
        /// Método para validar que no se repitan los datos del cliente con otro usuario
        /// </summary>
        /// <param name="oCliente"></param>
        /// <returns></returns>
        public DatosClienteDTO ValidarCliente(DatosClienteDTO oCliente)
        {
            bool _lStatus = false;

            DatosClienteDTO _oUsuario = new DatosClienteDTO();

            using (CHANGARROEntities ctx = new CHANGARROEntities())
            {
                if (ctx.tblCat_Cliente.Any(c => c.cCorreo == oCliente.cCorreo && c.iIdCliente != oCliente.iIdCliente))
                {
                    _lStatus          = true;
                    _oUsuario.cCorreo = oCliente.cCorreo;
                }
                if (ctx.tblCat_Cliente.Any(c => c.cTelefono == oCliente.cTelefono && c.iIdCliente != oCliente.iIdCliente))
                {
                    _lStatus            = true;
                    _oUsuario.cTelefono = oCliente.cTelefono;
                }
                if (ctx.tblCat_Cliente.Any(c => (c.cNombre + c.cApellido).Trim().ToLower() == (oCliente.cNombre + c.cApellido).Trim().ToLower() && c.iIdCliente != oCliente.iIdCliente))
                {
                    _lStatus            = true;
                    _oUsuario.cNombre   = oCliente.cNombre.ToLower();
                    _oUsuario.cApellido = oCliente.cApellido.ToLower();
                }
                if (_lStatus != true)
                {
                    _oUsuario = null;
                }
            }

            return(_oUsuario);
        }
Esempio n. 3
0
        public ActionResult MisDatos()
        {
            int iIdCliente = Convert.ToInt32(Session["iIdCliente"]);

            DatosClienteDTO _oCliente = oCliente.ObtenerDatosCliente(iIdCliente);

            return(PartialView(_oCliente));
        }
Esempio n. 4
0
        public JsonResult SubirImagen(HttpPostedFileBase file)
        {
            bool _lStatus;

            int iIdCliente = Convert.ToInt32(Session["iIdCliente"]);

            string _cNuevaImagen = null;

            string _cNombreImagen;

            Cliente _oCliente = new Cliente();

            try
            {
                DatosClienteDTO _oDatosCliente = _oCliente.ObtenerDatosCliente(iIdCliente);
                _oDatosCliente.cTelefono = _oDatosCliente.cTelefono != "N/A" ? _oDatosCliente.cTelefono : "imgDefCliente";
                _cNombreImagen           = _oDatosCliente.cNombre.First() + new string(_oDatosCliente.cTelefono.Take(9).ToArray());

                if (file != null || file.ContentLength != 0)
                {
                    Account account = new Account(

                        "blue-ocean-technologies",
                        "488187921138398",
                        "zqhipLe2tEf3tIr5FI_JAIQaU-I");

                    Cloudinary cloudinary = new Cloudinary(account);

                    ImageUploadParams uploadParams = new ImageUploadParams()
                    {
                        File      = new FileDescription(file.FileName, file.InputStream),
                        PublicId  = "Changarro/Clientes/" + _cNombreImagen,
                        Overwrite = true,
                    };

                    string _cImagen = String.Format(cloudinary.Upload(uploadParams).Version + "_" + _cNombreImagen);

                    _cNuevaImagen = _oCliente.CambiarImagen(iIdCliente, _cImagen);
                }

                _lStatus = true;
            }
            catch (Exception)
            {
                _lStatus = false;

                _cNuevaImagen = "Tu imagen no pudo ser actualizada, por favor intente más tarde";
            }

            return(Json(new { _lStatus, _cNuevaImagen }));
        }
Esempio n. 5
0
        /// <summary>
        /// Método para obtener los datos del cliente
        /// </summary>
        /// <param name="iIdCliente">ID del cliente</param>
        /// <returns>Objeto con los datos del cliente</returns>
        public DatosClienteDTO ObtenerDatosCliente(int iIdCliente)
        {
            DatosClienteDTO _oCliente = new DatosClienteDTO();

            using (CHANGARROEntities ctx = new CHANGARROEntities())
            {
                ctx.Configuration.LazyLoadingEnabled   = false;
                ctx.Configuration.ProxyCreationEnabled = false;

                _oCliente = ctx.tblCat_Cliente.AsNoTracking()
                            .Where(c => c.iIdCliente == iIdCliente)
                            .Select(o => new DatosClienteDTO
                {
                    cNombre   = o.cNombre,
                    cApellido = o.cApellido,
                    cTelefono = o.cTelefono,
                    cCorreo   = o.cCorreo
                }).FirstOrDefault();
            }
            return(_oCliente);
        }
Esempio n. 6
0
        /// <summary>
        /// Método para editar los datos del cliente
        /// </summary>
        /// <param name="oCliente">Objeto con los datos del cliente</param>
        /// <returns>Objeto con los nuevos datos del cliente</returns>
        public DatosClienteDTO EditarDatos(DatosClienteDTO oCliente)
        {
            using (CHANGARROEntities ctx = new CHANGARROEntities())
            {
                ctx.Configuration.LazyLoadingEnabled   = false;
                ctx.Configuration.ProxyCreationEnabled = false;

                tblCat_Cliente _oCliente = ctx.tblCat_Cliente.FirstOrDefault(c => c.iIdCliente == oCliente.iIdCliente);

                _oCliente.cNombre             = oCliente.cNombre;
                _oCliente.cApellido           = oCliente.cApellido;
                _oCliente.cTelefono           = oCliente.cTelefono;
                _oCliente.cCorreo             = oCliente.cCorreo;
                _oCliente.dtFechaModificacion = DateTime.Today;

                ctx.Entry(_oCliente).State = EntityState.Modified;

                ctx.SaveChanges();
            }

            return(oCliente);
        }