public Boolean CrearEvento(Eventos_ENT obj_evento)
{
try
{
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "Mi id Cliente",
ClientSecret = "Mi Cliente Secret",
},
new[] { CalendarService.Scope.Calendar },
"user",
CancellationToken.None).Result;
// Create the service
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Calendar API Sample",
});
Event myEvent = new Event
{
//Summary = "Appointment",
//Location = "Somewhere",
Summary = obj_evento.titulo_ev,
Location = obj_evento.ubicacion_ev,
Description = obj_evento.descripcion_eve,
HangoutLink = "",
Start = new EventDateTime()
{
//DateTime = new DateTime(2018, 7, 20, 10, 0, 0),
DateTime = obj_evento.FechaInicio,
TimeZone = obj_evento.TimeZone
},
End = new EventDateTime()
{
//DateTime = new DateTime(2018, 7, 21, 10, 30, 0),
DateTime = obj_evento.FechaFin,
TimeZone = obj_evento.TimeZone
},
Reminders = new Event.RemindersData()
{
UseDefault = false,
Overrides = new EventReminder[]
{
new EventReminder (){ Method="email", Minutes=24*60}
}
},
Recurrence = new String[] {
//"RRULE:FREQ=WEEKLY;BYDAY=MO"
obj_evento.Recurrencia
},
Attendees = obj_evento.Email.Select(m => new EventAttendee() { Email = m.Email,DisplayName=m.Nombre+" "+m.Apellido,ResponseStatus= "accepted" }).ToList(),
};
Event recurringEvent = service.Events.Insert(myEvent, "primary").Execute();
return true;
}
catch (Exception ex)
{
return false;
}
}