Example #1
0
        private async Task <Day> UpdateHolidayInfo(Day day)
        {
            var info = await _agendaService.RetrieveDateSigificanceData(day.Date);

            var dayInfo = info.dagar.FirstOrDefault();

            if (dayInfo != null)
            {
                if (!string.IsNullOrEmpty(dayInfo.helgdag))
                {
                    day.Events.Insert(0, AgendaModelFactory.CreateHolidayEvent(dayInfo.helgdag));
                }
                else if (!string.IsNullOrEmpty(dayInfo.helgdagsafton))
                {
                    day.Events.Insert(0, AgendaModelFactory.CreateHolidayEvent(dayInfo.helgdagsafton));
                }
            }

            return(day);
        }
Example #2
0
        private async Task <IReadOnlyList <Day> > GetCurrentEvents()
        {
            var events = await _agendaService.RetrieveCalendarData();

            var entryCount = 0d;
            var date       = DateTime.Today;

            var currentEvents = new List <Day>();

            while (entryCount < MAXIMUM_CONTENT)
            {
                var day = new Day
                {
                    Date = date
                };

                foreach (var eventData in events.Where(e => e.Start.Date == date && e.Start.Add(e.End - e.Start) >= DateTime.Now || (e.Start.Date < date && date < e.End.Date)).OrderBy(e => e.Start))
                {
                    var @event = AgendaModelFactory.CreateEvent(eventData);

                    day.Events.Add(@event);
                }

                await UpdateHolidayInfo(day);

                if (day.Events.Count > 0)
                {
                    currentEvents.Add(day);
                    entryCount += GetDayEntryCount(day);
                }

                date += TimeSpan.FromDays(1);
            }

            if (entryCount > MAXIMUM_CONTENT)
            {
                currentEvents.RemoveAt(currentEvents.Count - 1);
            }

            return(currentEvents);
        }