Imports System.Net.Http
Imports System.Net.Http.Headers
Imports WebIntranet.ClasesDatosAdmin

Public Class Idioma
    Inherits System.Web.UI.Page

    Protected Async Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'If (Session("persona") Is Nothing) Then
        '    ("Default.aspx", False)
        'Else

        Dim token As String = Session("token")
            Dim client As New HttpClient()
            client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("Bearer", token)
            client.BaseAddress = New Uri(ConfigurationManager.AppSettings("SwaggerVB"))
            Dim idPers = Session("persona").Personas(0).idPersona
        Dim url As String = "/api/IDIOMAS/GetWithIncludes/" & idPers
        Dim puestosItems = Await UtilAntifraude.ObtenerObjeto(Of List(Of IDIOMAS))(client, url)
        Dim htmlTabla = ""
        If (puestosItems.Count > 0) Then
            htmlTabla += "<table class='tablaPicadas'>" +
    "<tr><th>Idioma</th>" +
    "<th>Nivel</th>" +
    "<th>Centro de expedición</th>" +
    "<th>Año</th></tr>"
            For Each itm As IDIOMAS In puestosItems
                htmlTabla += "<tr>" +
                    "<td>" + itm.IDTIPOIDIOMANavigation?.DESCRIPCION + "</td>" +
                        "<td>" + itm.IDNIVELNavigation.DESCRIPCION + "</td>" +
                        "<td>" + itm.CENTROEXPEDICION + "</td>" +
                        "<td>" + itm.ANNO.ToString + "</td></tr>"
            Next
        htmlTabla += "</table>"
        Else
            htmlTabla += "<p style='color:red;font-weight:bold'>No se han encontrado resultados</p>"
        End If
        divTabla.InnerHtml = htmlTabla
        'End If
    End Sub

End Class