示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        private static string GenerateKey(string ownerUsername, Timeline.TimelineType type, DateTime date)
        {
            string dateString = date.ToString("yyyy-MM-dd");

            return(ownerUsername + "_" + type.ToString() + "_" + dateString);
        }
示例#4
0
        private string GenerateKeyFromMsg(Msg msg, Timeline.TimelineType type)
        {
            string owner = GetOwner(msg, type);

            return(GenerateKey(owner, type, msg.Created));
        }
示例#5
0
        public Timeline GetTimeline(string ownerUsername, Timeline.TimelineType type, DateTime date)
        {
            string timelineKey = GenerateKey(ownerUsername, type, date);

            return(timelineRepository.Get(timelineKey));
        }