예제 #1
0
        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);
            }
        }
예제 #2
0
 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()));
 }