Imports System
Imports System.Data
Imports System.Configuration
Imports ASPNET.StarterKit.TimeTracker.DataAccessLayer

Namespace ASPNET.StarterKit.TimeTracker.BusinessLogicLayer

    '****************************************************************************
    '
    ' Roles Class
    '
    ' The Roles class represents a list of custom Time Tracker roles.
    '
    '****************************************************************************

    Public Class Roles
        Private _name As String
        Private _roleID As Integer

        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal Value As String)
                _name = Value
            End Set
        End Property

        Public Property RoleID() As Integer
            Get
                Return _roleID
            End Get
            Set(ByVal Value As Integer)
                _roleID = Value
            End Set
        End Property

        Public Shared Function GetRoles() As RolesCollection
            Dim ds As DataSet = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings(Web.Global.CfgKeyConnString), "TT_ListAllRoles")
            Dim roleArray As New RolesCollection()

            ' Separate Data into a collection of Roles
            Dim r As DataRow
            For Each r In ds.Tables(0).Rows
                Dim role As New Roles()
                role.RoleID = Convert.ToInt32(r("RoleID"))
                role.Name = r("Name").ToString()

                roleArray.Add(role)
            Next r
            Return roleArray
        End Function 'GetRoles
    End Class 'Roles 
End Namespace 'ASPNET.StarterKit.TimeTracker.BusinessLogicLayer