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

    Namespace ASPNET.StarterKit.TimeTracker.BusinessLogicLayer

        '*********************************************************************
        '
        '    ProjectReportEntryLog Class
        '
        '    This class represents entry log item in Project Report page
        '
        '*********************************************************************

        Public Class ProjectReportEntryLog
            Private _duration As Decimal
            Private _fullName As String
            Private _maxEntryDate, _minEntryDate As DateTime
            Private _userID As Integer
            Private _userName As String

            Public Sub New()
                _userName = String.Empty
                _duration = 0D
                _userID = 0
                _minEntryDate = DateTime.MinValue
                _maxEntryDate = DateTime.MinValue
                _fullName = String.Empty
            End Sub 'New

            Public Property Duration() As Decimal
                Get
                    Return _duration
                End Get
                Set(ByVal Value As Decimal)
                    _duration = Value
                End Set
            End Property

            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 MaxEntryDate() As DateTime
                Get
                    Return _maxEntryDate
                End Get
                Set(ByVal Value As DateTime)
                    _maxEntryDate = Value
                End Set
            End Property

            Public Property MinEntryDate() As DateTime
                Get
                    Return _minEntryDate
                End Get
                Set(ByVal Value As DateTime)
                    _minEntryDate = Value
                End Set
            End Property

            '*********************************************************************
            '
            '    GetEntrySummary returns summary of each user's time entries based on category
            '
            '*********************************************************************

            Public Shared Function GetEntrySummary(ByVal categoryID As Integer) As ProjectReportEntryLogCollection
                Dim dsData As DataSet = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings(Web.Global.CfgKeyConnString), "TT_ListTimeEntriesByCategory", categoryID)
                Dim entryList As New ProjectReportEntryLogCollection()

                ' Separate Data into a collection of ProjectReportEntryLog.
                Dim row As DataRow
                For Each row In dsData.Tables(0).Rows
                    Dim entry As New ProjectReportEntryLog()
                    Dim firstName As String = String.Empty
                    Dim lastName As String = String.Empty

                    entry.UserName = row("UserName").ToString()
                    entry.Duration = Convert.ToDecimal(row("Duration"))
                    entry.UserID = Convert.ToInt32(row("UserID"))
                    entry.MinEntryDate = Convert.ToDateTime(row("MinEntryDate"))
                    entry.MaxEntryDate = Convert.ToDateTime(row("MaxEntryDate"))
                    entry.FullName = TTUser.GetDisplayName(entry.UserName, firstName, lastName)

                    entryList.Add(entry)
                Next row

                Return entryList
            End Function 'GetEntrySummary
        End Class 'ProjectReportEntryLog
    End Namespace 'ASPNET.StarterKit.TimeTracker.BusinessLogicLayer