public EventEntry UpdateOrCreateEvent(Event @event) { EnsureAuthentication(); if (string.IsNullOrEmpty(@event.Id)) { var eventEntry = new EventEntry(@event.Title); eventEntry.Content.Content = @event.Content; SetEventEntryTime(@event, eventEntry); return _calendarService.Insert(_calendarUri, eventEntry); } else { var eventEntry = GetEventEntryById(@event.Id); eventEntry.Content.Content = @event.Content; eventEntry.Title.Text = @event.Title; SetEventEntryTime(@event, eventEntry); return _calendarService.Update(eventEntry); } }
private static void SetEventEntryTime(Event @event, EventEntry eventEntry) { if (@event.StartTime.HasValue && @event.EndTime.HasValue && @event.StartTime.Value < @event.EndTime.Value) eventEntry.Times.Add(new When(@event.StartTime.GetValueOrDefault(), @event.EndTime.GetValueOrDefault())); }