Пример #1
0
        public bool Equals(TimeSlot t)
        {
            // If parameter is null return false:
            if ((object)t == null)
            {
                return false;
            }

            return (StartTime == t.StartTime) && (EndTime == t.EndTime);
        }
Пример #2
0
        private static void UpdateEventDataFromJsonData(EventAgenda eventData, IEnumerable<TalkData> talksJson)
        {
            var slots = new List<TimeSlot>();

            foreach (var t in talksJson)
            {
                var newTalk = new Talk
                {
                    Title = t.title,
                    Subtitle = t.subtitle,
                    Description = t.description,
                    Room = t.room,
                    Speaker = new Speaker
                    {
                        Name = t.speaker,
                        PictureUrl = t.speakerimage,
                        WebsiteUrl = t.speakerlink,
                        TwitterUrl = String.IsNullOrEmpty(t.speakertwitter) ? null : String.Format("https://www.twitter.com/{0}",t.speakertwitter)
                    }
                };

                var newSlot = new TimeSlot(t.slot);
                var existingSlot = slots.FirstOrDefault (s => newSlot.Equals(s));

                if (existingSlot == null) {
                    slots.Add(newSlot);
                }

                (existingSlot ?? newSlot).Talks.Add (newTalk);
            }

            // Link up timeslots
            foreach (var slot in slots)
            {
                foreach (var talk in slot.Talks)
                {
                    talk.TimeSlot = slot;
                }

                slot.Talks = slot.Talks.OrderBy (t => t.Room).ToList();
            }

            // Add slots to eventData
            foreach (var slot in slots.OrderBy (s => s.StartTime))
            {
                eventData.Slots.Add(slot);
            }
        }