Imports System.Collections.ObjectModel

Public Class bd_notasAlumnos
  Public Function ObtenerAsignatura(ID As Integer) As Asignatura
    Try
      Dim tablaAsigs As DataTable =
        DataSetBDNotasAlumnos.ObtenerTablaAsignaturas()
      Dim filaAsignaturas As DataRow =
        tablaAsigs.[Select]("id_asignatura = " & ID.ToString())(0)
      Dim asig As New Asignatura(
        CInt(filaAsignaturas("id_asignatura")),
        DirectCast(filaAsignaturas("nombre"), String))
      Return asig
    Catch exc As Exception
      System.Diagnostics.Debug.WriteLine(exc.Message)
      Return Nothing
    End Try
  End Function

  Public Function ObtenerAsignaturas() As ICollection(Of Asignatura)
    Dim tablaAsigs As DataTable = DataSetBDNotasAlumnos.ObtenerTablaAsignaturas()

    Dim asigs As New ObservableCollection(Of Asignatura)()

    For Each fila As DataRow In tablaAsigs.Rows
      asigs.Add(New Asignatura(CInt(fila("id_asignatura")), DirectCast(fila("nombre"), String)))
    Next
    Return asigs
  End Function

  ' ...
End Class
