Imports Nancy
Imports PAAServices.ExternalConnection

Namespace i9activitiesViewer.Controllers

    Public Class AtividadesController
        Inherits NancyModule

        Sub New()
            [Get]("api/activities/") = Function(r) GetAtividades()
            [Get]("api/schoolname/") = Function(r) GetSchoolName()
        End Sub

        Private Function GetAtividades() As Responses.Negotiation.Negotiator
            Return Negotiate.
                WithStatusCode(HttpStatusCode.OK).
                WithContentType("application/json").
                WithModel(ExternalConnection.GetActivitiesBetweenDates())
        End Function

        Private Function GetSchoolName() As Responses.Negotiation.Negotiator
            Dim escola = DadosEscola.DadosEscolaService.Get()

            Dim objAnon = New With {.SchoolName = escola.Nome}

            Return Negotiate.
                WithStatusCode(HttpStatusCode.OK).
                WithContentType("application/json").
                WithModel(objAnon)
        End Function
    End Class

End Namespace