Event creation.

This commit is contained in:
Burak Kaan Köse
2026-03-07 17:13:48 +01:00
parent d1f8163d72
commit ebc35c3de8
21 changed files with 921 additions and 161 deletions
+16 -6
View File
@@ -128,9 +128,7 @@ public class CalendarService : BaseDatabaseService, ICalendarService
public async Task DeleteCalendarItemAsync(string calendarRemoteEventId, Guid calendarId)
{
var calendarItem = await Connection.FindWithQueryAsync<CalendarItem>(
"SELECT * FROM CalendarItem WHERE CalendarId = ? AND RemoteEventId = ?",
calendarId, calendarRemoteEventId);
var calendarItem = await FindCalendarItemByRemoteEventIdAsync(calendarId, calendarRemoteEventId).ConfigureAwait(false);
if (calendarItem == null) return;
@@ -244,9 +242,7 @@ public class CalendarService : BaseDatabaseService, ICalendarService
public async Task<CalendarItem> GetCalendarItemAsync(Guid accountCalendarId, string remoteEventId)
{
var calendarItem = await Connection.FindWithQueryAsync<CalendarItem>(
"SELECT * FROM CalendarItem WHERE CalendarId = ? AND RemoteEventId = ?",
accountCalendarId, remoteEventId);
var calendarItem = await FindCalendarItemByRemoteEventIdAsync(accountCalendarId, remoteEventId).ConfigureAwait(false);
await LoadAssignedCalendarAsync(calendarItem);
@@ -481,6 +477,20 @@ public class CalendarService : BaseDatabaseService, ICalendarService
private static DateTime MaxDateTime(DateTime first, DateTime second)
=> first >= second ? first : second;
private Task<CalendarItem> FindCalendarItemByRemoteEventIdAsync(Guid calendarId, string remoteEventId)
{
if (string.IsNullOrWhiteSpace(remoteEventId))
return Task.FromResult<CalendarItem>(null);
var providerRemoteEventId = remoteEventId.GetProviderRemoteEventId();
return Connection.FindWithQueryAsync<CalendarItem>(
"SELECT * FROM CalendarItem WHERE CalendarId = ? AND (RemoteEventId = ? OR RemoteEventId LIKE ?)",
calendarId,
providerRemoteEventId,
$"{providerRemoteEventId}::%");
}
private sealed class CalendarReminderCandidate
{
public Guid CalendarItemId { get; set; }