public Calendar Get(string id, DateTime begin, DateTime end)
        {
            var entries = new List <Reservation>();
            var chunks  = _session.Load <CalendarChunk>(CalendarChunkHelper.CreateChunkIds(id, begin, end))
                          .Values.Where(x => x != null).SelectMany(x => x.Entries).ToList();

            foreach (var groupedChunks in chunks.GroupBy(x => x.CalendarEntryId))
            {
                var firstChunk = groupedChunks.First();
                var lastChunk  = groupedChunks.Last();
                var entry      = new Reservation(groupedChunks.Key, id, firstChunk.Begin, lastChunk.End);
                entries.Add(entry);
            }

            return(new Calendar(id, new CalendarBounds(begin, end), entries));
        }
        public void Update(Calendar calendar)
        {
            var days      = CalendarChunkHelper.SplitIntoChunks(calendar).ToList();
            var exisiting = _session.Load <CalendarChunk>(days.Select(x => x.Id));

            foreach (var calendarDay in days)
            {
                if (exisiting.ContainsKey(calendarDay.Id) && exisiting[calendarDay.Id] != null)
                {
                    exisiting[calendarDay.Id].Update(calendarDay.Entries);
                }
                else
                {
                    _session.Store(calendarDay);
                }
            }
        }