Ejemplo n.º 1
0
        public static Usuario GetUserById(int IdUser)
        {
            UsuarioTableAdapter localAdapter = new UsuarioTableAdapter();

            if (IdUser <= 0)
            {
                return(null);
            }

            Usuario theUser = null;

            try
            {
                UsuarioDS.UsuarioDataTable table = localAdapter.GetUsuarioById(IdUser);

                if (table != null && table.Rows.Count > 0)
                {
                    UsuarioDS.UsuarioRow row = table[0];
                    theUser = FillUserRecord(row);
                }
            }
            catch (Exception q)
            {
                log.Error("An error was ocurred while geting user data", q);
                return(null);
            }

            return(theUser);
        }
Ejemplo n.º 2
0
 private static Usuario GetUsuarioFromRow(UsuarioDS.UsuarioRow row)
 {
     return(new Usuario()
     {
         correo = row.correo,
         usuarioId = row.usuarioId,
         nombreCompleto = row.nombre,
         codigoActivacion = row.IscodigoActivacionNull() ? "" : row.codigoActivacion,
         codigoRecuperacion = row.IscodigoRecuperacionNull() ? "" : row.codigoRecuperacion
     });
 }
Ejemplo n.º 3
0
 private static Usuario GetUsuarioFromRow(UsuarioDS.UsuarioRow row)
 {
     return(new Usuario()
     {
         UsuarioID = row.UsuarioId,
         Nombre = row.Nombre,
         Apellido = row.Apellido,
         Telefono = row.Telefono,
         Correo = row.Correo,
         Contrasena = DesEncriptarPassword(row.Contraseña),
         EstadoEspera = row.EstadoEspera,
         EstadoCuenta = row.EstadoCuenta
     });
 }
Ejemplo n.º 4
0
        private static Usuario FillUserRecord(UsuarioDS.UsuarioRow row)
        {
            Usuario theNewRecord = new Usuario(
                row.usuarioId,
                row.Nombre,
                row.IsapellidoNull() ? "" : row.apellido,
                row.IspasswordNull() ? "" : row.password,
                row.tipoUsuarioId,
                row.IsemailNull() ? "" : row.email,
                row.Iscelular1Null() ? "" : row.celular1,
                row.Iscelular2Null() ? "" : row.celular2,
                row.IsnitNull() ? 0 : row.nit);

            return(theNewRecord);
        }
Ejemplo n.º 5
0
    public static Usuario autenticarUsuario(string username, string password)
    {
        UsuarioTableAdapter adapter = new UsuarioTableAdapter();

        UsuarioDS.UsuarioDataTable table = adapter.autenticarUsuario(username, password);

        if (table == null || table.Rows.Count > 1)
        {
            throw new Exception("La consulta retornó un numero incorrecto de filas");
        }
        if (table.Rows.Count == 0)
        {
            return(null);
        }
        UsuarioDS.UsuarioRow row = table[0];
        return(new Usuario()
        {
            correo = row.correo,
            usuarioId = row.usuarioId,
            nombreCompleto = row.nombre
        });
    }