Example #1
0
        private async Task <EventHomepage> AddHomepageRowEvents(EventHomepage homepage)
        {
            var events = await _cache.GetFromCacheOrDirectlyAsync("event-all", GetAllEvents, _eventsTimeout);

            var liveEvents = GetAllEventsAndTheirReccurrences(events)
                             .Where(e => _dateComparer.EventDateIsBetweenTodayAndLater(e.EventDate))
                             .OrderBy(e => e.EventDate)
                             .ThenBy(c => c.StartTime)
                             .ThenBy(t => t.Title)
                             .ToList();

            liveEvents = GetNextOccurenceOfEvents(liveEvents);

            foreach (var row in homepage.Rows)
            {
                if (row.IsLatest)
                {
                    row.Events = liveEvents.Take(3);
                }
                else
                {
                    row.Events = liveEvents.Where(e => e.Tags.Contains(row.Tag.ToLower())).Take(3);
                }
            }

            return(homepage);
        }