public async Task <ILoadedAppointment> UpdateAppointmentAsync(ILoadedAppointment existingAppointment, IAppointment appointmentData, bool force) { using (Logger.Scope($"GoogleCalendar.UpdateAppointment(\"{existingAppointment}\")")) { var googleAppointment = existingAppointment as GoogleCalendarAppointment ?? throw new ArgumentException("Cannot update appointment from a different calendar"); return(await UpdateAppointmentAsync(googleAppointment.GoogleCalendarEventId, googleAppointment.Sequence, appointmentData, force).ConfigureAwait(false)); } }
public async Task DeleteAppointmentAsync(ILoadedAppointment appointment) { using (Logger.Scope($"GoogleCalendar.UpdateAppointment(\"{appointment}\")")) { var googleAppointment = appointment as GoogleCalendarAppointment ?? throw new ArgumentException("Cannot delete appointment from a different calendar"); EventsResource.DeleteRequest request = _service.Events.Delete(CalendarId, googleAppointment.GoogleCalendarEventId); await request.ExecuteAsync().ConfigureAwait(false); Logger.Verbose($"Deleted event \"{appointment}\" on {appointment.Schedule?.Start:d}"); } }
public static string ToLongString(this ILoadedAppointment appointment) { var sb = new StringBuilder(); sb.AppendLine(appointment.UniqueId); sb.AppendLine(); sb.AppendLine(appointment.Busy ? "Busy" : "Free"); if (!appointment.Confirmed) { sb.AppendLine("Tentative"); } sb.AppendLine(appointment.Subject); sb.AppendLine(appointment.Location); sb.AppendLine(); if (appointment.Schedule == null) { sb.AppendLine("No schedule"); } else if (appointment.Schedule.AllDay && appointment.Schedule.Start.Date.AddDays(1) == appointment.Schedule.End.Date) { sb.AppendLine($"{appointment.Schedule.Start.ToShortDateString()}"); } else if (appointment.Schedule.AllDay) { sb.AppendLine($"{appointment.Schedule.Start.ToShortDateString()} - {appointment.Schedule.End.AddDays(-1).ToShortDateString()}"); } else if (appointment.Schedule.Start.Date == appointment.Schedule.End.Date) { sb.AppendLine($"{appointment.Schedule.Start} - {appointment.Schedule.End.ToShortTimeString()}"); } else { sb.AppendLine($"{appointment.Schedule.Start} - {appointment.Schedule.End}"); } if (appointment.Schedule?.Recurrence != null) { sb.AppendLine(); sb.AppendLine($"{appointment.Schedule.Recurrence.Frequency} recurrence!"); } return(sb.ToString()); }