Ejemplo n.º 1
0
        public void AddEvent(CalendarEvent calendarEvent)
        {
            UserCredential credential = GetCredentials();

            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = "GoSync"
            });

            var googleEvent = new Event();

            googleEvent.End = new EventDateTime()
            {
                DateTime = calendarEvent.DateTo
            };
            googleEvent.Start = new EventDateTime()
            {
                DateTime = calendarEvent.DateFrom
            };
            googleEvent.Summary     = calendarEvent.Title;
            googleEvent.Description = calendarEvent.Description;
            googleEvent.Location    = calendarEvent.Location;

            googleEvent.ExtendedProperties        = new Event.ExtendedPropertiesData();
            googleEvent.ExtendedProperties.Shared = new Dictionary <string, string>();

            googleEvent.ExtendedProperties.Shared["SourceID"] = calendarEvent.GetKey();

            var response = service.Events.Insert(googleEvent, "primary").Execute();
        }