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

    Namespace ASPNET.StarterKit.TimeTracker.BusinessLogicLayer
        '*********************************************************************
        '
        '    ResourceReportUser Class
        '
        '    This class represents User summary in Resource Report page
        '
        '*********************************************************************

        Public Class ResourceReportUser
            Private _fullName As String
            Private _userID As Integer
            Private _userName As String
            Private _totalHours As Decimal

            Public Sub New()
                _userID = 0
                _userName = String.Empty
                _totalHours = 0D
                _fullName = String.Empty
            End Sub 'New

            Public Property FullName() As String
                Get
                    Return _fullName
                End Get
                Set(ByVal Value As String)
                    _fullName = Value
                End Set
            End Property

            Public Property UserID() As Integer
                Get
                    Return _userID
                End Get
                Set(ByVal Value As Integer)
                    _userID = Value
                End Set
            End Property

            Public Property UserName() As String
                Get
                    Return _userName
                End Get
                Set(ByVal Value As String)
                    _userName = Value
                End Set
            End Property

            Public Property TotalHours() As Decimal
                Get
                    Return _totalHours
                End Get
                Set(ByVal Value As Decimal)
                    _totalHours = Value
                End Set
            End Property

            '*********************************************************************
            '
            ' GetUserSummary retrieves multiple user summaries and returns them in a collection.
            ' userIdList is a comma delimited UserIDs string (i.e. "1,2,3").
            '
            '*********************************************************************

            Public Shared Function GetUserSummary(ByVal mgrUserID As Integer, ByVal userIdList As String, ByVal startDate As DateTime, ByVal endDate As DateTime) As ResourceReportUserCollection
                Dim dsUsers As DataSet = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings(Web.Global.CfgKeyConnString), "TT_ListUserTimeSummary", mgrUserID, userIdList, startDate, endDate)
                Dim userList As New ResourceReportUserCollection()

                ' Create a reference to display full name.
                Dim firstName As String = String.Empty
                Dim lastName As String = String.Empty

                ' Separate Data into a collection of ResourceReportUser
                Dim row As DataRow
                For Each row In dsUsers.Tables(0).Rows
                    Dim usr As New ResourceReportUser()
                    usr.UserID = Convert.ToInt32(row("UserID"))
                    usr.UserName = row("UserName").ToString()
                    usr.TotalHours = Convert.ToDecimal(row("TotalHours"))
                    usr.FullName = TTUser.GetDisplayName(usr.UserName, firstName, lastName)

                    userList.Add(usr)
                Next row
                Return userList
            End Function 'GetUserSummary
        End Class 'ResourceReportUser
    End Namespace 'ASPNET.StarterKit.TimeTracker.BusinessLogicLayer