예제 #1
0
        public void ActualizarPerfil()
        {
            //var rm = new ResponseModel();

            try
            {
                using (var dbwanlla = new db_wanlla())
                {
                    //dbwanlla.Configuration.ValidateOnSaveEnabled = false;

                    //var eUsuario = dbwanlla.Entry(this);
                    dbwanlla.Entry(this).Property(x => x.id_usuario).IsModified = false;
                    //if (this.nom_usuario == null) eUsuario.Property(x => x.nom_usuario).IsModified = false;
                    dbwanlla.Entry(this).Property(x => x.pass_usuario).IsModified = false;
                    dbwanlla.Entry(this).State = EntityState.Modified;
                    //Obviar campos o ignorar en la actualización



                    dbwanlla.SaveChanges();
                    //rm.SetResponse(true);
                }
            }
            //catch (DbEntityValidationException e)
            //{
            //    throw;
            //}
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
 public void Guardar()
 {
     using (var db = new db_wanlla())
     {
         db.Entry(this).State = EntityState.Added;
         db.SaveChanges();
     }
 }
예제 #3
0
 public void Guardar()
 {
     try
     {
         using (var dbwanlla = new db_wanlla())
         {
             if (this.id_distribuidor > 0)
             {
                 dbwanlla.Entry(this).State = EntityState.Modified;
             }
             else
             {
                 dbwanlla.Entry(this).State = EntityState.Added;
             }
             dbwanlla.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
 /// <summary>
 /// Manteniemiento (Agregar, Modificar) Dieta
 /// </summary>
 public void mantenimiento()
 {
     try
     {
         using (var db = new db_wanlla())
         {
             if (this.id_dieta > 0)
             {
                 db.Entry(this).State = EntityState.Modified;
             }
             else
             {
                 db.Entry(this).State = EntityState.Added;
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #5
0
 public void Eliminar()
 {
     try
     {
         using (var dbwanlla = new db_wanlla())
         {
             dbwanlla.Entry(this).State = EntityState.Deleted;
             dbwanlla.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #6
0
 public void actualizar()
 {
     try
     {
         using (var db = new db_wanlla())
         {
             db.Entry(this).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #7
0
 public void guardar()
 {
     try
     {
         using (var db = new db_wanlla())
         {
             db.Entry(this).State = EntityState.Added;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #8
0
 public void eliminar()
 {
     try
     {
         using (var db = new db_wanlla())
         {
             db.Entry(this).State = System.Data.Entity.EntityState.Deleted;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #9
0
 public void confirmarPedido()
 {
     try
     {
         using (var db = new db_wanlla())
         {
             this.est_pedido      = "Confirmado";
             db.Entry(this).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #10
0
 public void registrar()
 {
     try
     {
         using (var db = new db_wanlla())
         {
             this.pass_usuario    = BCrypt.Net.BCrypt.HashPassword(this.pass_usuario, BCrypt.Net.BCrypt.GenerateSalt());
             db.Entry(this).State = EntityState.Added;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #11
0
        public ResponseModel eliminar()
        {
            var rm = new ResponseModel();

            try
            {
                using (var db = new db_wanlla())
                {
                    db.Entry(this).State = EntityState.Deleted;
                    rm.SetResponse(true);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(rm);
        }
예제 #12
0
        /// <summary>
        /// Cambiar password del Usuario
        /// </summary>
        public void cambiarPassword(string new_pass, int id_usuario)
        {
            try
            {
                using (var db = new db_wanlla())
                {
                    var usu = db.usuario
                              .Where(x => x.id_usuario == id_usuario)
                              .SingleOrDefault();

                    usu.pass_usuario    = BCrypt.Net.BCrypt.HashPassword(new_pass, BCrypt.Net.BCrypt.GenerateSalt());
                    db.Entry(usu).State = EntityState.Modified;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #13
0
        public ResponseModel Guardar(HttpPostedFileBase Foto)

        {
            var rm = new ResponseModel();

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

                    var eCategoria = db.Entry(this);
                    if (this.id_categoria > 0)
                    {
                        eCategoria.State = EntityState.Modified;

                        if (Foto != null)
                        {
                            String archivo = Path.GetFileName(Foto.FileName); //*Path.GetExtension(Foto.FileName);

                            //String archivo = DateTime.Now.ToString("yyyyMMddMMss") + Path.GetFileName(Foto.FileName);

                            Foto.SaveAs(HttpContext.Current.Server.MapPath("~/images/" + archivo));


                            this.img_categoria = archivo;
                        }
                        else
                        {
                            eCategoria.Property(x => x.img_categoria).IsModified = false;
                        }

                        db.SaveChanges();
                        rm.SetResponse(true);
                    }
                    else
                    {
                        eCategoria.State = EntityState.Added;

                        if (Foto != null)
                        {
                            String archivo = Path.GetFileName(Foto.FileName); //*Path.GetExtension(Foto.FileName);

                            //String archivo = DateTime.Now.ToString("yyyyMMddMMss") + Path.GetFileName(Foto.FileName);

                            Foto.SaveAs(HttpContext.Current.Server.MapPath("~/images/" + archivo));


                            this.img_categoria = archivo;
                        }
                        else
                        {
                            eCategoria.Property(x => x.img_categoria).IsModified = false;
                        }
                        db.SaveChanges();
                        rm.SetResponse(true);
                    }
                }
            }
            catch (DbEntityValidationException e)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
            return(rm);
        }