private async Task UpdateCalendar(ResourceCalendar calendar) { Cache.ClearAll(); DjangoCalendar dc = await GetDjangoCalendar(calendar); foreach (var newEntry in ParseEntries(calendar)) { var old = dc.Results.FirstOrDefault(row => row.Start == newEntry.Start && row.End == newEntry.End); if (old != null) { old.Used = true; } else { dc.Results.Add(newEntry); } } foreach (var entry in dc.Results) { if (entry.ID != null && entry.Used) { continue; } if (entry.ID != null) { await DeleteItem(entry.ID); } else { await PostJson("calendarentries/", Serialize(entry)); } } }
private async Task FillResourceCalendar(ResourceCalendar calendar) { DjangoCalendar dc = await GetDjangoCalendar(calendar); foreach (var reserved in dc.Results) { reserved.Start = reserved.Start; reserved.End = reserved.End; FillReserved(reserved, calendar); } }