diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLogList.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLogList.cs index 92fa59b..9b7bb36 100644 --- a/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLogList.cs +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLogList.cs @@ -15,7 +15,8 @@ namespace Interfaces public int TimeLogCount { get { return TimeLogs.Values.Sum(x => x.LogCount); } } public Dictionary TimeLogs { get; set; } public double WeeklyTotal { - get { return TimeLogs.Values.Sum(x => x.DailyTotal)/60.0d; } + get { return TimeLogs.Values.Sum(x => x.DailyTotal); } } + public float HoursPerWeekMinutes { get; set; } } } \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs index 4169e1b..1c0d8d3 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs @@ -22,5 +22,7 @@ namespace SQLiteRepository public const string GET_ALL_USERS_PAGINATE = "select * from "+ nameof(UserIdentity)+" limit ? offset ?"; public const string GET_TOTAL_USER_COUNT = "select Max("+nameof(UserIdentity.Id)+") from " + nameof(UserIdentity); + + public const string GET_USER_CONTRACTED_HOURS = "select "+nameof(UserIdentity.HoursPerWeek)+ " From UserIdentity where " + nameof(UserIdentity.Id) + "=?"; } } \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs index 6d504fb..e2598be 100644 --- a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs @@ -168,25 +168,10 @@ namespace SQLiteRepository return ret; } - + //TODO: refac this as it duplicates a lot of code. public TimeLogList GetTimeLogs(int userId) { - var ret = new TimeLogList(); - //get this calendar week; - var now = DateTime.UtcNow; - var calendarWeek = GetIso8601CalendarWeek(now); - ret.CalendarWeek = calendarWeek; - ret.SelectedDate = now.Date; - try - { - ret.TimeLogs = GetTimeLogList(userId, calendarWeek, now.Year); - } - catch (Exception ex) - { - _logger.Error(ex, "Error in GetTimeLogs with Id: {0}, Exception: {1}", userId, ex); - } - - return ret; + return GetTimeLogs(userId, DateTime.UtcNow); } public TimeLogList GetTimeLogs(int userId, DateTime selectedDate) @@ -204,9 +189,28 @@ namespace SQLiteRepository _logger.Error(ex, "Error in GetTimeLogs with Id: {0} and selected date: {1}, Exception: {2}", userId, selectedDate, ex); } + try + { + ret.HoursPerWeekMinutes = GetUserContractedHours(userId)*60.0f; + } + catch (Exception ex) + { + _logger.Error(ex, "Error in GetUserContracterHours with Id: {0} and selected date: {1}, Exception: {2}", userId, selectedDate, ex); + } + return ret; } + private float GetUserContractedHours(int userId) + { + var hoursQuery = _connection.Query(SQLiteProcedures.GET_USER_CONTRACTED_HOURS, userId); + if (hoursQuery.Any()) + { + return hoursQuery.First().HoursPerWeek; + } + return -1.0f; + } + public IdentifierList GetUnassignedIdentifierList() { var ret = new IdentifierList(); diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/index.html b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/index.html index ba5cebd..9804490 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/index.html +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/index.html @@ -205,6 +205,7 @@
+ @@ -219,60 +220,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
Monday8
Tuesday8
Wednesday8
Thursday8
Friday8
Weekly Total37
Monday8
Weekly Total