示例#1
0
        public ResponseModel GuardarPassword(HttpPostedFileBase Pass)
        {
            var rm = new ResponseModel();

            try
            {
                using (var db = new db_ventas())
                {
                    db.Configuration.ValidateOnSaveEnabled = false;

                    var eUsuario = db.Entry(this);
                    eUsuario.State = EntityState.Modified;
                    //Obviar campos o ignorar en la actualización
                    if (Pass != null)
                    {
                        //String archivo = Path.GetFileName(Foto.FileName);//Path.GetExtension(Foto.FileName);

                        //Nombre de imagen en forma aleatoria
                        //String archivo = DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(Foto.FileName);

                        //Colocar la ruta donde se grabará
                        //Foto.SaveAs(HttpContext.Current.Server.MapPath("~/Uploads/" + archivo));

                        //enviar al modelo el nombre del archivo
                        //this.FOTO = archivo;
                    }
                    else
                    {
                        eUsuario.Property(x => x.PASSWORD).IsModified = false;  // el campo no es obligatorio
                    }
                    if (this.NOMBREUSU == null)
                    {
                        eUsuario.Property(x => x.NOMBREUSU).IsModified = false;
                    }

                    if (this.FOTO == null)
                    {
                        eUsuario.Property(x => x.FOTO).IsModified = false;
                    }

                    if (this.EMAIL == null)
                    {
                        eUsuario.Property(x => x.EMAIL).IsModified = false;
                    }

                    db.SaveChanges();
                    rm.SetResponse(true);
                }
            }
            catch (DbEntityValidationException e)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
            return(rm);
        }
示例#2
0
 public void eliminar()
 {
     try
     {
         using (var db = new db_ventas())
         {
             db.Entry(this).State = EntityState.Deleted;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#3
0
 public void mantenimiento()
 {
     try
     {
         using (var db = new db_ventas())
         {
             if (this.IDPEDIDO > 0)
             {
                 db.Entry(this).State = EntityState.Modified;
             }
             else
             {
                 db.Entry(this).State = EntityState.Added;
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#4
0
        //public void Guardar()
        //{
        //    try
        //    {
        //        using (var db = new db_ventas())
        //        {
        //            if (this.IDUSUARIO == "")
        //            {
        //                db.Entry(this).State = EntityState.Modified;
        //            }
        //            else
        //            {
        //                db.Entry(this).State = EntityState.Added;
        //            }
        //            db.SaveChanges();
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        throw;
        //    }
        //}

        public void Guardar()
        {
            try
            {
                using (var db = new db_ventas())
                {
                    if (this.IDUSUARIO != 0)
                    {
                        db.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        db.Entry(this).State = EntityState.Added;
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }