public ResponseModel ValidarLogin(string Usuario, string Contraseña)
        {
            var rm = new ResponseModel();

            Contraseña = HashHelper.SHA1(Contraseña);

            try
            {
                using (var db = new ModeloGGYM())
                {
                    //Contraseña = HashHelper.SHA1(Contraseña);

                    var usuario = db.USUARIO.Where(x => x.EMAIL == Usuario)
                                  .Where(x => x.PASSWORD == Contraseña)
                                  .SingleOrDefault();

                    if (usuario != null)
                    {
                        SessionHelper.AddUserToSession(usuario.ID_USUARIO.ToString());
                        rm.SetResponse(true);
                        rm.idtipo = usuario.ID_TIPOUSUARIO;
                    }
                    else
                    {
                        rm.SetResponse(false, "Usuario y/o Password incorrectos");
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(rm);
        }
        public void RegistarEntrenador()
        {
            this.ESTADO = true;

            try
            {
                using (var db = new ModeloGGYM())
                {
                    if (this.ID_USUARIO > 0)
                    {
                        db.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        DateTime now = DateTime.Now;
                        this.PASSWORD        = HashHelper.SHA1(this.PASSWORD);
                        this.ID_TIPOUSUARIO  = 3;
                        this.FECHA_CREACION  = Convert.ToDateTime(now.ToString("yyyy/MM/dd hh:mm:ss"));
                        db.Entry(this).State = EntityState.Added;
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
        public void Habilitar()
        {
            var usuario = ObtenerUsuario(ID_USUARIO);

            this.ID_USUARIO     = usuario.ID_USUARIO;
            this.NOMBRE         = usuario.NOMBRE;
            this.APELLIDO       = usuario.APELLIDO;
            this.FECHA_CREACION = usuario.FECHA_CREACION;
            this.TELEFONO       = usuario.TELEFONO;
            this.DIRECCION      = usuario.DIRECCION;
            this.PESO           = usuario.PESO;
            this.ESTATURA       = usuario.ESTATURA;
            this.EDAD           = usuario.EDAD;
            this.EMAIL          = usuario.EMAIL;
            this.PASSWORD       = usuario.PASSWORD;
            this.ID_TIPOUSUARIO = usuario.ID_TIPOUSUARIO;
            this.ID_MEMBRESIA   = usuario.ID_MEMBRESIA;
            this.ESTADO         = true;
            try
            {
                using (var db = new ModeloGGYM())
                {
                    if (this.ID_USUARIO > 0)
                    {
                        db.Entry(this).State = EntityState.Modified;
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
Exemple #4
0
        public void RegistarSeguimiento(int idusuario, string pesousuario)
        {
            //EL DIA DE HOY
            DateTime now = DateTime.Now;

            now = Convert.ToDateTime(now.ToString("dd/MM/yyyy"));

            var seguimiento = ObtenerSeguimientoPorFecha(now, idusuario);

            this.ID_USUARIO = idusuario;
            this.PESO       = pesousuario;

            if (seguimiento == null)
            {
                // SIGNIFICA QUE ES UN NUEVO DATO
                this.FECHA = Convert.ToDateTime(now.ToString("dd/MM/yyyy"));

                try
                {
                    using (var db = new ModeloGGYM())
                    {
                        db.Entry(this).State = EntityState.Added;
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    throw;
                }
            }

            else
            {
                // NO HACE NADA PORQUE SIGNIFICA QUE SON IGUALES
                // QUEDARIA COMPARAR LOS PESOS SI NO SON IGUALES PARA ACTUALIZAR
                if (!this.PESO.Equals(seguimiento.PESO))
                {
                    this.ID_SEGUIMIENTO = seguimiento.ID_SEGUIMIENTO;
                    this.ID_USUARIO     = seguimiento.ID_USUARIO;
                    this.FECHA          = seguimiento.FECHA;

                    try
                    {
                        using (var db = new ModeloGGYM())
                        {
                            db.Entry(this).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                    catch (Exception e)
                    {
                        throw;
                    }
                }
                else
                {
                    // AHORA SI NO HACE NADA
                }
            }
        }
Exemple #5
0
        public void Habilitar()
        {
            var membresia = ObtenerMembresia(ID_MEMBRESIA);

            this.ID_MEMBRESIA = membresia.ID_MEMBRESIA;
            this.DESCRIPCION  = membresia.DESCRIPCION;
            this.DURACION     = membresia.DURACION;
            this.COSTO        = membresia.COSTO;
            this.ESTADO       = true;
            try
            {
                using (var db = new ModeloGGYM())
                {
                    if (this.ID_MEMBRESIA > 0)
                    {
                        db.Entry(this).State = EntityState.Modified;
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
        public void RegistarHorario(int idregistro, int iduser, int idhorario)
        {
            DateTime now = DateTime.Now;

            this.FECHA_CREACION = Convert.ToDateTime(now.ToString("yyyy/MM/dd hh:mm:ss"));
            this.ID_USUARIO     = iduser;
            this.ID_HORARIO     = idhorario;
            this.ID_REGISTRO    = idregistro;

            try
            {
                using (var db = new ModeloGGYM())
                {
                    if (this.ID_REGISTRO > 0)
                    {
                        db.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        db.Entry(this).State = EntityState.Added;
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
Exemple #7
0
 public void RegistrarHorario()
 {
     try
     {
         using (var db = new ModeloGGYM())
         {
             db.Entry(this).State = EntityState.Added;
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }
        public List <USUARIO> ListarTodo()
        {
            var usuarios = new List <USUARIO>();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    usuarios = db.USUARIO.Include("TIPO_USUARIO").ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(usuarios);
        }
        public List <PRODUCTO> ListarTodo()
        {
            var productos = new List <PRODUCTO>();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    productos = db.PRODUCTO.Include("CATEGORIA_PRODUCTO").ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(productos);
        }
Exemple #10
0
        public List <HORARIO> ListarTodo()
        {
            var horario = new List <HORARIO>();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    horario = db.HORARIO.Include("REGISTRO").ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(horario);
        }
Exemple #11
0
        public List <MEMBRESIA> ListarTodo()
        {
            var membresia = new List <MEMBRESIA>();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    membresia = db.MEMBRESIA.OrderBy(x => x.COSTO).ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(membresia);
        }
        public List <REGISTRO> ListarTodo()
        {
            var registro = new List <REGISTRO>();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    registro = db.REGISTRO.Include("USUARIO").Include("HORARIO")
                               .ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(registro);
        }
        public PRODUCTO ObtenerProducto(int id)
        {
            var producto = new PRODUCTO();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    producto = db.PRODUCTO.Include("CATEGORIA_PRODUCTO")
                               .Where(x => x.ID_PRODUCTO == id)
                               .SingleOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(producto);
        }
        public USUARIO ObtenerRespaldo(string EmailRecuperar)
        {
            var usuario = new USUARIO();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    usuario = db.USUARIO.Include("TIPO_USUARIO")
                              .Where(x => x.EMAIL == EmailRecuperar)
                              .SingleOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(usuario);
        }
        public USUARIO ObtenerUsuario(int id)
        {
            var usuario = new USUARIO();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    usuario = db.USUARIO.Include("TIPO_USUARIO")
                              .Where(x => x.ID_USUARIO == id)
                              .SingleOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(usuario);
        }
Exemple #16
0
        public SEGUIMIENTO ObtenerSeguimientoPorFecha(DateTime diahoy, int id)
        {
            var seguimiento = new SEGUIMIENTO();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    seguimiento = db.SEGUIMIENTO
                                  .Where(x => x.FECHA.Value == diahoy && x.ID_USUARIO == id)
                                  .SingleOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(seguimiento);
        }
Exemple #17
0
        public IMC ObtenerIMC(int idusuario)
        {
            var imcchiquito = new IMC();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    imcchiquito = db.IMC
                                  .Where(x => x.ID_USUARIO == idusuario)
                                  .SingleOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(imcchiquito);
        }
Exemple #18
0
        public SEGUIMIENTO ObtenerSeguimiento(int id)
        {
            var seguimiento = new SEGUIMIENTO();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    seguimiento = db.SEGUIMIENTO
                                  .Where(x => x.ID_SEGUIMIENTO == id)
                                  .SingleOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(seguimiento);
        }
Exemple #19
0
        public MEMBRESIA ObtenerMembresia(int id)
        {
            var membresia = new MEMBRESIA();

            try
            {
                using (var db = new ModeloGGYM())
                {
                    membresia = db.MEMBRESIA
                                .Where(x => x.ID_MEMBRESIA == id)
                                .SingleOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(membresia);
        }
        public void RegistrarMembresia()
        {
            this.ESTADO = true;

            try
            {
                using (var db = new ModeloGGYM())
                {
                    if (this.ID_USUARIO > 0)
                    {
                        this.ID_TIPOUSUARIO  = 2;
                        db.Entry(this).State = EntityState.Modified;
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
Exemple #21
0
        public void RegistrarIMC(int idusuario, string imcTemporal)
        {
            var imcchiquito = ObtenerIMC(idusuario);

            this.ID_USUARIO = idusuario;
            this.IMC1       = imcTemporal;

            if (imcchiquito == null)
            {
                try
                {
                    using (var db = new ModeloGGYM())
                    {
                        db.Entry(this).State = EntityState.Added;
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    throw;
                }
            }
            else
            {
                this.ID_IMC = imcchiquito.ID_IMC;

                try
                {
                    using (var db = new ModeloGGYM())
                    {
                        db.Entry(this).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    throw;
                }
            }
        }
 public void RegistrarProducto()
 {
     try
     {
         using (var db = new ModeloGGYM())
         {
             if (this.ID_PRODUCTO > 0)
             {
                 db.Entry(this).State = EntityState.Modified;
             }
             else
             {
                 db.Entry(this).State = EntityState.Added;
             }
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }
Exemple #23
0
        public void RegistrarMembresia()
        {
            this.ESTADO = true;

            try
            {
                using (var db = new ModeloGGYM())
                {
                    if (this.ID_MEMBRESIA > 0)
                    {
                        db.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        db.Entry(this).State = EntityState.Added;
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }