예제 #1
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
        });
    }