Exemplo n.º 1
0
        private List <EventOccurrency> GetEventOccurrencies(List <MyCalendarEvent> myCalendarEvents, Ical.Net.Calendar calendar, DateTime searchStart, DateTime searchEnd)
        {
            var occurrencies = calendar.GetOccurrences(searchStart, searchEnd);
            var events       = new List <EventOccurrency>();

            foreach (var occurrency in occurrencies)
            {
                var myCalendarEvent = myCalendarEvents.FirstOrDefault(e => e.Start.Value.TimeOfDay == occurrency.Period.StartTime.Value.TimeOfDay);
                if (myCalendarEvent != null)
                {
                    events.Add(new EventOccurrency
                    {
                        Offset = myCalendarEvent.Offset,
                        Start  = occurrency.Period.StartTime.Value,
                        End    = occurrency.Period.EndTime.Value,
                    });
                }
            }
            return(events.OrderBy(e => e.Start).ToList());
        }