예제 #1
0
        public bool ConsultarJwt(string Jwt)
        {
            bool jwt = false;

            try
            {
                table_jwt jwtResult = null;
                using (WantgoProdEntities ctx = new WantgoProdEntities())
                {
                    var request = from item in ctx.table_jwt
                                  where item.jwt == Jwt
                                  select item;

                    jwtResult = request.FirstOrDefault <table_jwt>();

                    if (jwtResult != null)
                    {
                        return(jwt = true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex.InnerException;
            }
            return(jwt);
        }
        public seguimiento_usuario_pais follow_countries(seguimiento_usuario_pais seguir)
        {
            seguimiento_usuario_pais result = new seguimiento_usuario_pais();

            try
            {
                using (WantgoProdEntities ctx = new WantgoProdEntities())
                {
                    var query = (from u in ctx.usuario where u.id_usuario == seguir.id_usuario select u).FirstOrDefault();
                    if (query != null)
                    {
                        seguimiento_usuario_pais newSeguirPaises = new seguimiento_usuario_pais
                        {
                            id_usuario = seguir.id_usuario,
                            id_pais    = seguir.id_pais
                        };
                        ctx.seguimiento_usuario_pais.Add(newSeguirPaises);
                        ctx.SaveChanges();
                        result = newSeguirPaises;
                    }
                    else
                    {
                        result = null;
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public DataUsuario ConsultarUsuario(LoginRequest login)
        {
            DataUsuario usuario = new DataUsuario();

            try
            {
                using (WantgoProdEntities ctx = new WantgoProdEntities())
                {
                    var result = (from item in ctx.usuario
                                  join p in ctx.pais on item.id_Pais equals p.id_Pais
                                  where item.correo == login.email &&
                                  item.password == login.password
                                  select new
                    {
                        item.id_usuario,
                        item.usuario1,
                        item.correo,
                        item.Sexo,
                        item.telefono,
                        item.foto_Perfil,
                        item.pasaporte,
                        p.nombre,
                        p.ruta_logo
                    });

                    if (result != null)
                    {
                        foreach (var u in result)
                        {
                            DataUsuario dataUsuario = new DataUsuario()
                            {
                                id_usuario  = u.id_usuario,
                                usuario     = u.usuario1,
                                correo      = u.correo,
                                foto_Perfil = u.foto_Perfil,//cambio solicitado
                                pais        = u.nombre,
                                Sexo        = u.Sexo,
                                telefono    = u.telefono,
                                foto_pais   = u.ruta_logo,
                                pasaporte   = u.pasaporte
                            };
                            usuario = dataUsuario;
                        }
                        return(usuario);
                    }
                }
            }

            catch (Exception ex)
            {
                return(null);
            }
            return(usuario);
        }
예제 #4
0
 public int GetLastId()
 {
     try
     {
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var user = ctx.usuario.Max(u => u.id_usuario);
             return(user);
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
예제 #5
0
 public DataProfile GetProfile(RequestProfile request)
 {
     try
     {
         DataProfile dataProfile = new DataProfile();
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var query = (from u in ctx.usuario
                          join pa in ctx.pais on u.id_Pais equals pa.id_Pais
                          join per in ctx.perfil on u.id_usuario equals per.id_usuario
                          into Perfil
                          from pe in Perfil.DefaultIfEmpty()
                          where u.id_usuario == request.UserId
                          select new DataProfile
             {
                 UserId = u.id_usuario,
                 Names = pe.nombre_usuario,
                 UserName = u.usuario1,
                 Sex = u.Sexo,
                 PhoneNumber = u.telefono,
                 Email = u.correo,
                 Description = pe.descripcion,
                 UserPhoto = u.foto_Perfil,
                 CountryPhoto = pa.ruta_logo,
                 CountryDeal = pa.deal_Pais.ToString()
             }).FirstOrDefault();
             if (query != null)
             {
                 dataProfile = query;
                 dataProfile.ListPreferences = new List <string>();
                 var preferences = (from p in ctx.preferencias_usuario
                                    join pre in ctx.preferencias on p.id_Preferencias equals pre.id_Preferencias
                                    where p.id_usuario == query.UserId
                                    select pre).ToList();
                 foreach (var item in preferences)
                 {
                     dataProfile.ListPreferences.Add(item.descripcion);
                 }
             }
         }
         return(dataProfile);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #6
0
 public usuario ConsultarUsuarioEmail(LoginRequest login)
 {
     try
     {
         usuario _usuario = new usuario();
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var query = (from u in ctx.usuario where u.correo == login.email select u).FirstOrDefault();
             _usuario = query;
         }
         return(_usuario);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #7
0
        public usuario CreateUsuario(usuario user, List <int> preferences)
        {
            usuario result = new usuario();

            try
            {
                using (WantgoProdEntities ctx = new WantgoProdEntities())
                {
                    usuario newUser = new usuario
                    {
                        usuario1  = user.usuario1,
                        password  = user.password,
                        Sexo      = user.Sexo,
                        correo    = user.correo,
                        telefono  = user.telefono,
                        id_Pais   = user.id_Pais,
                        pasaporte = user.pasaporte
                    };
                    ctx.usuario.Add(newUser);
                    ctx.SaveChanges();
                    result = newUser;
                    if (result != null)
                    {
                        if (preferences != null)
                        {
                            foreach (var item in preferences)
                            {
                                preferencias_usuario newPreferencia = new preferencias_usuario
                                {
                                    id_Preferencias = item,
                                    id_usuario      = newUser.id_usuario
                                };
                                ctx.preferencias_usuario.Add(newPreferencia);
                                ctx.SaveChanges();
                            }
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #8
0
        public long EliminarJwt(string Jwt)
        {
            long id = -1;

            try
            {
                using (WantgoProdEntities ctx = new WantgoProdEntities())
                {
                    var acceso = ctx.table_jwt.Where(c => c.jwt == Jwt).FirstOrDefault();
                    ctx.table_jwt.Remove(acceso);
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex.InnerException;
            }
            return(id);
        }
        public experiencia ExperienceCreate(ExperienceEntity experience)
        {
            experiencia result = new experiencia();

            using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                try
                {
                    int IdExperience = 0;
                    using (WantgoProdEntities ctx = new WantgoProdEntities())
                    {
                        experiencia newExperience = new experiencia
                        {
                            id_Categoria = experience.CategoryId,
                            id_Pais      = experience.CountryId,
                            direccion    = experience.Address,
                            descripcion  = experience.Description
                        };
                        ctx.experiencia.Add(newExperience);
                        ctx.SaveChanges();
                        IdExperience = newExperience.id_Experiencia;
                        if (IdExperience > 0)
                        {
                            usuario_experiencia newUserExperiece = new usuario_experiencia
                            {
                                id_Experiencia = IdExperience,
                                id_usuario     = experience.UserId
                            };
                            ctx.usuario_experiencia.Add(newUserExperiece);
                            ctx.SaveChanges();
                        }
                        result = newExperience;
                    }
                    txscope.Complete();
                }
                catch (Exception ex)
                {
                    txscope.Dispose();
                    throw ex;
                }
            }
            return(result);
        }
예제 #10
0
 public bool ValidarUsuario(string email)
 {
     try
     {
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var query = (from u in ctx.usuario where u.correo == email select u).FirstOrDefault();
             if (query != null)
             {
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #11
0
 public bool validPassportNumber(string passport)
 {
     try
     {
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var query = (from u in ctx.usuario where u.pasaporte == passport select u).FirstOrDefault();
             if (query != null)
             {
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public List <categoria> GetCategories()
 {
     try
     {
         List <categoria> CategoriesList = null;
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var query = (from c in ctx.categoria select c);
             if (query != null)
             {
                 CategoriesList = query.ToList();
             }
             return(CategoriesList);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List <preferencias> GetPreferences()
 {
     try
     {
         List <preferencias> PreferencesList = null;
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var query = (from p in ctx.preferencias where p.estado == true select p);
             if (query != null)
             {
                 PreferencesList = query.ToList();
             }
             return(PreferencesList);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public bool PaisSeguido(seguirPaises seguir)
 {
     try
     {
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var query = (from u in ctx.seguimiento_usuario_pais
                          where u.id_pais == seguir.id_Pais && u.id_usuario == seguir.id_Usuario select u).FirstOrDefault();
             if (query != null)
             {
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #15
0
        public int ConsultarUsuarioId(int Id)
        {
            int result = 0;

            try
            {
                using (WantgoProdEntities ctx = new WantgoProdEntities())
                {
                    var query = (from u in ctx.usuario where u.id_usuario == Id select u).FirstOrDefault();
                    if (query != null)
                    {
                        result = query.id_usuario;
                    }
                }
                return(result);
            }
            catch (Exception)
            {
                return(result);
            }
        }
예제 #16
0
 public bool ActualizarRutaFotoUsuario(string ruta, string email)
 {
     try
     {
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var query = (from u in ctx.usuario where u.correo == email select u).FirstOrDefault();
             if (query != null)
             {
                 query.foto_Perfil = ruta;
                 ctx.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #17
0
        public JwtParametros ConsultarPropiedadesJwt(long Id)
        {
            try
            {
                JwtParametros result = null;

                using (WantgoProdEntities context = new WantgoProdEntities())
                {
                    var request = from item in context.JwtParametros
                                  where item.ID == Id && item.STATUS == true
                                  select item;

                    result = request.FirstOrDefault <JwtParametros>();
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex.InnerException;
            }
        }
예제 #18
0
        public long CreateJwt(table_jwt jwt)
        {
            int result = -1;

            try
            {
                var       ctx   = new WantgoProdEntities();
                table_jwt token = new table_jwt()
                {
                    jwt = jwt.jwt
                };
                ctx.table_jwt.Add(token);
                result = ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex.InnerException;
            }

            return(result);
        }
예제 #19
0
        public List <pais> Getcountries()
        {
            try
            {
                List <pais> listQuery = new List <pais>();

                using (WantgoProdEntities ctx = new WantgoProdEntities())
                {
                    var query = (from t in ctx.pais select t);

                    if (query != null)
                    {
                        listQuery = query.ToList();
                    }
                }
                return(listQuery);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public bool ExperienceUpdatePath(string ruta, int ExperienceId)
        {
            bool result = false;

            try
            {
                using (WantgoProdEntities ctx = new WantgoProdEntities())
                {
                    var entidad = (from e in ctx.experiencia where e.id_Experiencia == ExperienceId select e).FirstOrDefault();
                    if (entidad != null)
                    {
                        entidad.ruta_multimedia = ruta;
                        ctx.SaveChanges();
                        result = true;
                    }
                }
                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #21
0
 public bool ChangePassword(RequestChangePassword request)
 {
     try
     {
         bool result = false;
         using (WantgoProdEntities ctx = new WantgoProdEntities())
         {
             var query = (from u in ctx.usuario
                          where request.UserId == u.id_usuario && request.OldPassword == u.password
                          select u).FirstOrDefault();
             if (query != null)
             {
                 query.password = request.NewPassword;
                 ctx.SaveChanges();
                 result = true;
             }
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #22
0
        public bool UpdateProfile(UpdateProfile request)
        {
            try
            {
                bool result = false;
                using (WantgoProdEntities ctx = new WantgoProdEntities())
                {
                    var query = (from u in ctx.usuario where u.id_usuario == request.UserId select u).FirstOrDefault();
                    if (query != null)
                    {
                        var profile   = (from p in ctx.perfil where p.id_usuario == query.id_usuario select p).FirstOrDefault();
                        var emergency = (from e in ctx.contacto_emergencia where e.id_usuario == query.id_usuario select e).FirstOrDefault();

                        query.Sexo     = request.Sex;
                        query.telefono = request.PhoneNumber;
                        query.usuario1 = request.UserName;
                        query.correo   = request.Email;
                        if (profile != null)
                        {
                            profile.nombre_usuario   = request.Names;
                            profile.apellido_usuario = request.LastNames;
                            profile.descripcion      = request.Description;
                            profile.cedula           = request.Document;
                            profile.rh = request.Rh;
                            profile.ciudad_nacimiento = request.BornCity;
                            profile.ocupacion         = request.Ocupation;
                            profile.idiomas           = request.Languages;
                            profile.fecha_nacimiento  = request.DateBorn;
                            profile.numero_pasaporte  = request.PassporNumber;
                        }
                        else
                        {
                            perfil nuevoPerfil = new perfil
                            {
                                nombre_usuario   = request.Names,
                                apellido_usuario = request.LastNames,
                                descripcion      = request.Description,
                                cedula           = request.Document,
                                rh = request.Rh,
                                ciudad_nacimiento = request.BornCity,
                                ocupacion         = request.Ocupation,
                                idiomas           = request.Languages,
                                fecha_nacimiento  = request.DateBorn,
                                numero_pasaporte  = request.PassporNumber
                            };
                            ctx.perfil.Add(nuevoPerfil);
                        }

                        if (emergency != null)
                        {
                            emergency.nombre   = request.EmergencyName;
                            emergency.telefono = request.EmergencyPhone;
                            emergency.correo   = request.EmergencyEmail;
                        }
                        else
                        {
                            contacto_emergencia emergencia = new contacto_emergencia
                            {
                                nombre     = request.EmergencyName,
                                correo     = request.EmergencyEmail,
                                telefono   = request.EmergencyPhone,
                                id_usuario = request.UserId
                            };
                            ctx.contacto_emergencia.Add(emergencia);
                        }

                        ctx.SaveChanges();
                        result = true;
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }