private static string GetOwner(Msg msg, Timeline.TimelineType type) { switch (type) { case Timeline.TimelineType.Inbox: return(msg.Recipient); case Timeline.TimelineType.Sent: return(msg.Sender); } return(msg.Recipient); }
private void AddToTimeline(Msg msg, Timeline.TimelineType type, string msgKey) { string timelineKey = GenerateKeyFromMsg(msg, type); Timeline timeline = timelineRepository.Get(key: timelineKey, notFoundOK: true); if (timeline != null) { timeline = AddToExistingTimeline(timeline, msgKey); } else { timeline = CreateNewTimeline(timelineKey, msgKey); } timelineRepository.Save(timeline); }
private static string GenerateKey(string ownerUsername, Timeline.TimelineType type, DateTime date) { string dateString = date.ToString("yyyy-MM-dd"); return(ownerUsername + "_" + type.ToString() + "_" + dateString); }
private string GenerateKeyFromMsg(Msg msg, Timeline.TimelineType type) { string owner = GetOwner(msg, type); return(GenerateKey(owner, type, msg.Created)); }
public Timeline GetTimeline(string ownerUsername, Timeline.TimelineType type, DateTime date) { string timelineKey = GenerateKey(ownerUsername, type, date); return(timelineRepository.Get(timelineKey)); }