Ejemplo n.º 1
0
        //Metodod ValidarLogin
        public spmClsResponseModel ValidarLogin(string Usuario, string Password)
        {
            var rm = new spmClsResponseModel();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    //Password = spmClsHashHelper.SHA1(Password); //Encriptar Password

                    var usuario = db.spmUSUtUsuario.Where(x => x.USUnombre_usuario == Usuario) //Sentencia LINQ
                                  .Where(x => x.USUcontraseña == Password)
                                  .SingleOrDefault();

                    if (usuario != null)
                    {
                        spmClsSessionHelper.AddUserToSession(usuario.USUid.ToString());
                        rm.SetResponse(true);
                    }
                    else
                    {
                        rm.SetResponse(false, "Usuario o Password incorrecto...");
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(rm);
        }
Ejemplo n.º 2
0
 //Metodo Eliminar
 public void Eliminar()
 {
     try
     {
         using (var db = new Modelo_Sistema())
         {
             db.Entry(this).State = EntityState.Deleted; //elimina el registro
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 3
0
        //-----------------------------------------------------------------------------------------------------------------

        //Metodo Listar
        public List <spmUSUtUsuario> Listar() //Retorna una colleccion
        {
            var objUsuario = new List <spmUSUtUsuario>();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    objUsuario = db.spmUSUtUsuario.ToList(); //codigo LINQ
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(objUsuario);
        }
Ejemplo n.º 4
0
        public List <spmRECpReceta> ListarRecetas() //retorna una collection
        {
            var objIngrediente = new List <spmRECpReceta>();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    objIngrediente = db.spmRECpReceta.ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(objIngrediente);
        }
Ejemplo n.º 5
0
        // METODO LISTAR
        //*****************************************************************
        public List <spmRINpReceta_Ingrediente> Listar() //retorna una collection
        {
            var objRecetaIngre = new List <spmRINpReceta_Ingrediente>();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    objRecetaIngre = db.spmRINpReceta_Ingrediente.Include("spmINGtIngrediente").Include("spmRECpReceta").ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(objRecetaIngre);
        }
Ejemplo n.º 6
0
        // METODO LISTAR
        //*****************************************************************
        public List <spmPADtPadecimiento_Salud> Listar() //retorna una collection
        {
            var objSalud = new List <spmPADtPadecimiento_Salud>();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    objSalud = db.spmPADtPadecimiento_Salud.ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(objSalud);
        }
Ejemplo n.º 7
0
        // METODO LISTAR
        //*****************************************************************
        public List <spmRECpReceta> Listar() //retorna una collection
        {
            var objReceta = new List <spmRECpReceta>();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    objReceta = db.spmRECpReceta.Include("spmPADtPadecimiento_Salud").Include("spmUSUtUsuario").ToList();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(objReceta);
        }
Ejemplo n.º 8
0
        //METODO OBTENER
        //*****************************************************************
        public spmINGtIngrediente Obtener(int id) // retorna solo un objeto
        {
            var objIngrediente = new spmINGtIngrediente();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    objIngrediente = db.spmINGtIngrediente.Where(x => x.INGid == id)
                                     .SingleOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(objIngrediente);
        }
Ejemplo n.º 9
0
        //METODO OBTENER
        //*****************************************************************
        public spmRINpReceta_Ingrediente Obtener(int id) // retorna solo un objeto
        {
            var objRecetaIngre = new spmRINpReceta_Ingrediente();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    objRecetaIngre = db.spmRINpReceta_Ingrediente.Include("spmINGtIngrediente").Include("spmRECpReceta").Where(x => x.RECid == id)
                                     .SingleOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(objRecetaIngre);
        }
Ejemplo n.º 10
0
        //METODO OBTENER
        //*****************************************************************
        public spmRECpReceta Obtener(int id) // retorna solo un objeto
        {
            var objReceta = new spmRECpReceta();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    objReceta = db.spmRECpReceta.Include("spmPADtPadecimiento_Salud").Include("spmUSUtUsuario").Where(x => x.RECid == id)
                                .SingleOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(objReceta);
        }
Ejemplo n.º 11
0
        //Metodo Obtener
        public spmUSUtUsuario Obtener(int id) //Retorna solo un objeto,por eso no se pone list
        {
            var objUsuario = new spmUSUtUsuario();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    objUsuario = db.spmUSUtUsuario
                                 .Where(x => x.USUid == id)
                                 .SingleOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(objUsuario);
        }
Ejemplo n.º 12
0
 //Metodo Guardar
 public void Guardar()
 {
     try
     {
         using (var db = new Modelo_Sistema())
         {
             if (this.USUid > 0)
             {
                 //si existe un valor mayor a cero, es porque existe el registro
                 db.Entry(this).State = EntityState.Modified;
             }
             else
             {
                 //si no existe el registro lo guarda(nuevo)
                 db.Entry(this).State = EntityState.Added;
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 13
0
        //Metodod Actualizar Perfil Personal
        public spmClsResponseModel GuardarPerfil(HttpPostedFileBase USUfoto)
        {
            var rm         = new spmClsResponseModel();
            var objUsuario = new spmUSUtUsuario();

            try
            {
                using (var db = new Modelo_Sistema())
                {
                    db.Configuration.ValidateOnSaveEnabled = false;
                    var Usu = db.Entry(this);
                    Usu.State = EntityState.Modified;

                    if (USUfoto != null)
                    {
                        string extension = Path.GetExtension(USUfoto.FileName).ToLower();
                        int    size      = 1024 * 1024 * 5;

                        var filtroextension = new[] { ".jpg", ".jpeg", ".png", ".gif", ".PNG", ".JPEG" };
                        var extensiones     = Path.GetExtension(USUfoto.FileName);

                        if (filtroextension.Contains(extensiones) && (USUfoto.ContentLength <= size))
                        {
                            string archivo = Path.GetFileName(USUfoto.FileName);
                            USUfoto.SaveAs(HttpContext.Current.Server.MapPath("~/Archivos/" + archivo));

                            this.USUfoto = archivo;
                        }
                    }

                    else
                    {
                        Usu.Property(x => x.USUfoto).IsModified = false;
                    }

                    if (this.USUid == 0)
                    {
                        Usu.Property(x => x.USUid).IsModified = false;
                    }
                    if (this.USUnombre == null)
                    {
                        Usu.Property(x => x.USUnombre).IsModified = false;
                    }
                    if (this.USUapellido == null)
                    {
                        Usu.Property(x => x.USUapellido).IsModified = false;                           //true para permitir cambiar
                    }
                    if (this.USUnombre_usuario == null)
                    {
                        Usu.Property(x => x.USUnombre_usuario).IsModified = false;
                    }
                    if (this.USUcontraseña == null)
                    {
                        Usu.Property(x => x.USUcontraseña).IsModified = false;
                    }
                    if (this.USUcorreo_electronico == null)
                    {
                        Usu.Property(x => x.USUcorreo_electronico).IsModified = false;
                    }

                    db.SaveChanges();
                    rm.SetResponse(true);
                }
            }
            catch (DbEntityValidationException e)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
            return(rm);
        }