/// <summary> /// Record this guy as having been visited. /// </summary> /// <param name="meeting"></param> /// <param name="startTime"></param> /// <param name="title"></param> public async Task MarkVisitedNow(IMeeting m, DateTime?timeStamp = null) { // Setup the time stamp var ts = timeStamp.HasValue ? timeStamp.Value : DateTime.Now; await CreateDBConnection(); // See if this meeting is already in the database. We have to // use the unique string for that, sadly. var mref = m.AsReferenceString(); var entry = await(_db.AsyncConnection.Table <IWalker.MRU>().Where(mt => mt.IDRef == mref).FirstOrDefaultAsync()); if (entry == null) { // Totally new! var mru = new IWalker.MRU() { IDRef = mref, StartTime = m.StartTime, Title = m.Title, LastLookedAt = ts }; var r = await _db.AsyncConnection.InsertAsync(mru); _mrusUpdated.OnNext(default(Unit)); } else { // Just update a pre-existing object. entry.LastLookedAt = DateTime.Now; // And update all the other fields entry.Title = m.Title; entry.StartTime = m.StartTime; await _db.AsyncConnection.UpdateAsync(entry); _mrusUpdated.OnNext(default(Unit)); } }
public void MergedListKeepRightOne() { var l1 = new IWalker.MRU[] { new IWalker.MRU { Id = 10, IDRef = "hiref", Title = "this is it", StartTime = DateTime.Now, LastLookedAt = DateTime.Parse("1/20/2010") } }; var l2 = new IWalker.MRU[] { new IWalker.MRU { Id = 10, IDRef = "hiref", Title = "this is not it", StartTime = DateTime.Now, LastLookedAt = DateTime.Parse("1/20/2011") } }; MRUSettingsCache.UpdateForMachine("M1", l1); MRUSettingsCache.UpdateForMachine("M2", l2); var l = MRUSettingsCache.GetAllMachineMRUMeetings(); Assert.AreEqual(1, l.Length); Assert.AreEqual("this is not it", l[0].Title); }