fixup! add foreach to group logs by the day of the week in which they are entered. #15

This commit is contained in:
chris.watts90@outlook.com 2017-02-13 22:26:52 +00:00 committed by Chris.Watts90@outlook.com
parent 906ec10a5b
commit a2cb93bf83
3 changed files with 17 additions and 3 deletions

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Interfaces; using Interfaces;
using SQLite.Net; using SQLite.Net;
using SQLite.Net.Platform.Win32; using SQLite.Net.Platform.Win32;
@ -369,8 +370,7 @@ namespace SQLiteRepository
var timeLogList = _connection.Query<TimeLogDb>( var timeLogList = _connection.Query<TimeLogDb>(
SQLiteProcedures.GET_TIMELOGS, SQLiteProcedures.GET_TIMELOGS,
userId, calendarWeek, year); userId, calendarWeek, year);
var timeLogs = timeLogList.Select(x => new TimeLog
var ret = timeLogList.Select(x => new TimeLog
{ {
Id = x.Id, Id = x.Id,
CalendarWeek = x.CalendarWeek, CalendarWeek = x.CalendarWeek,
@ -380,6 +380,19 @@ namespace SQLiteRepository
UserId = x.UserId_FK, UserId = x.UserId_FK,
Year = x.Year Year = x.Year
}).ToList(); }).ToList();
var dict = new Dictionary<DayOfWeek, List<TimeLog>>();
foreach (var log in timeLogs)
{
var dow = log.EventTime.DayOfWeek;
if (!dict.ContainsKey(dow))
{
dict.Add(dow, new List<TimeLog>());
}
dict[dow].Add(log);
}
var ret = timeLogs;
return ret; return ret;
} }

View File

@ -23,6 +23,7 @@ namespace WindowsDataCenter
if(repo == null) throw new ArgumentNullException(nameof(repo)); if(repo == null) throw new ArgumentNullException(nameof(repo));
_repo = repo; _repo = repo;
if(logger == null) throw new ArgumentNullException(nameof(logger)); if(logger == null) throw new ArgumentNullException(nameof(logger));
_logger = logger;
} }
/// <summary> /// <summary>

View File

@ -35,7 +35,7 @@
} }
var url = "timelogs" + "/" + userId; var url = "timelogs" + "/" + userId;
if (args) { if (args) {
url = self.createRequestUrl(url, args, false, true); url = self.createRequestUrl(url, args, false, false);
} }
location.hash = url; location.hash = url;
}; };