public async Task <ActionResult <Event> > DeleteEvent(long id) { var @event = await repository.DeleteAsync(id); if (@event == null) { return(NotFound()); } return(@event); }
/// <summary> /// Removes an event from the user's default calendar. /// </summary> /// <param name="selectedEventId">string. The unique Id of the event to delete.</param> /// <returns></returns> internal async Task <IEvent> DeleteCalendarEventAsync(string selectedEventId) { IEvent thisEvent = null; try { // Make sure we have a reference to the calendar client var calendarClient = await AuthenticationHelper.EnsureOutlookClientCreatedAsync(); // Get the event to be removed from the Exchange service. This results in a call to the service. var thisEventFetcher = calendarClient.Me.Calendar.Events.GetById(selectedEventId); thisEvent = await thisEventFetcher.ExecuteAsync(); // Delete the event. This results in a call to the service. await thisEvent.DeleteAsync(false); } catch (Exception) { throw new Exception("Your calendar event was not deleted on the Exchange service"); } return(thisEvent); }
public static async Task DeleteEvent(IEvent calendarEvent) { await calendarEvent.DeleteAsync(); }