예제 #1
0
        public void LoadGlobalCalendar(DateTime start, DateTime end)
        {
            var globalCalendar = ApplicationCache.Get <Dictionary <DateTime, Dictionary <string, bool> > >(Global.GlobalCalendar);

            foreach (var calendarEvent in _calendarEventRepository.GetByRange <CalendarEvent>(start, end))
            {
                var dateKey = calendarEvent.Start.Date;
                while (dateKey < calendarEvent.End.Date)
                {
                    if (!globalCalendar.ContainsKey(dateKey))
                    {
                        globalCalendar[dateKey] = new Dictionary <string, bool>();
                    }

                    calendarEvent.SaftyInvoke <Holiday>(h =>
                    {
                        globalCalendar[dateKey][h.Country] = true;
                    });

                    calendarEvent.SaftyInvoke <DaylightSavingTime>(d =>
                    {
                        globalCalendar[dateKey][d.TimeZone.Id] = true;
                    });

                    dateKey = dateKey.AddDays(1);
                }
            }
        }