Imports System.Net.Http
Imports System.Net.Http.Headers

Imports WebIntranet.ClasesDatosAdmin

Public Class Puestos
    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
        '    Response.Redirect("~/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/VIDA_ADMINISTRATIVA/puestospersona/" & idPers
        Dim puestosItems = Await UtilAntifraude.ObtenerObjeto(Of List(Of PuestoPersona))(client, url)

        Dim htmlTabla = ""
        If (puestosItems.Count > 0) Then

            htmlTabla += "<table class='tablaPicadas'>" +
"<tr><th>Puesto de trabajo</th>" +
"<th>Nivel</th>" +
"<th>Clase personal</th>" +
"<th>Grupo</th>" +
"<th>Fecha inicio</th>" +
"<th>Fecha fin</th>" +
"<th>Caracter Ocupación</th>" +
"<th>Años</th>" +
"<th>Meses</th>" +
"<th>Días</th></tr>"
            For Each itm As PuestoPersona In puestosItems
                htmlTabla += "<tr>" +
                        "<td>" + itm.Puesto + "</td>" +
                        "<td>" + itm.Nivel + "</td>" +
                        "<td>" + itm.Adscripcion + "</td>" +
                        "<td>" + itm.Grupo + "</td>" +
                        "<td>" + If(Not itm.FechaToPo = Nothing, itm.FechaToPo.ToString("dd/MM/yyyy"), "") + "</td>" +
                        "<td>" + If(Not itm.FechaCese = Nothing, itm.FechaCese.ToString("dd/MM/yyyy"), "") + "</td>" +
                        "<td>" + itm.CaracterOcu + "</td>" +
                        "<td>" + itm.AnosSer.ToString + "</td>" +
                        "<td>" + itm.MesesSer.ToString + "</td>" +
                        "<td>" + itm.DiasSer.ToString + "</td></tr>"
            Next
            htmlTabla += "</table>"
        Else
            htmlTabla += "<p style='color:red;font-weight:bold'>No se han encontrado resultados</p>"
        End If
        divTablaPuestos.InnerHtml = htmlTabla
        'End If


    End Sub



End Class