Skip to content

Commit

Permalink
Return CalendarItemIdentifier for iOS/macOS (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfversluis authored Oct 2, 2023
1 parent 86ada9b commit d795865
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions samples/Plugin.Maui.CalendarStore.Sample/AddEventsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,32 @@ async void Save_Clicked(object sender, EventArgs e)
var startEndDateTime = new DateTime(EventEndDate.Year, EventEndDate.Month,
EventEndDate.Day, EventEndTime.Hours, EventEndTime.Minutes, EventEndTime.Seconds);

string savedEventId = string.Empty;

// Check if we're updating an event
if (eventToUpdate is not null)
{
await calendarStore.UpdateEvent(eventToUpdate.Id, EventTitle, EventDescription,
EventLocation, startDateTime, startEndDateTime, EventIsAllDay);

await DisplayAlert("Event saved", $"The event has been successfully updated!", "OK");
}
else
{
// We could also not use this overload and just provide EventIsAllDay as a parameter
if (EventIsAllDay)
{
await calendarStore.CreateAllDayEvent(SelectedCalendar.Id, EventTitle,
savedEventId = await calendarStore.CreateAllDayEvent(SelectedCalendar.Id, EventTitle,
EventDescription, EventLocation, startDateTime, startEndDateTime);
}
else
{
await calendarStore.CreateEvent(SelectedCalendar.Id, EventTitle,
savedEventId = await calendarStore.CreateEvent(SelectedCalendar.Id, EventTitle,
EventDescription, EventLocation, startDateTime, startEndDateTime);
}
}

await DisplayAlert("Event saved", "The event has been successfully saved!", "OK");
await DisplayAlert("Event saved", $"The event has been successfully saved with ID: {savedEventId}!", "OK");
}

await Shell.Current.Navigation.PopAsync();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.Maui.CalendarStore/CalendarStore.macios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public async Task<string> CreateEvent(string calendarId, string title, string de
throw new CalendarStoreException("Saving the event was unsuccessful.");
}

return eventToSave.EventIdentifier;
return eventToSave.CalendarItemIdentifier;
}

/// <inheritdoc/>
Expand Down

0 comments on commit d795865

Please sign in to comment.