Reminders.

This commit is contained in:
Burak Kaan Köse
2026-01-01 15:02:40 +01:00
parent 3b485dc1fe
commit a64627e7d6
14 changed files with 420 additions and 24 deletions
+33
View File
@@ -20,10 +20,15 @@ namespace Wino.Services;
public class CalendarService : BaseDatabaseService, ICalendarService
{
// Predefined reminder options in minutes
private static readonly int[] PredefinedReminderMinutes = [60, 30, 15, 5, 1];
public CalendarService(IDatabaseService databaseService) : base(databaseService)
{
}
public int[] GetPredefinedReminderMinutes() => PredefinedReminderMinutes;
public Task<List<AccountCalendar>> GetAccountCalendarsAsync(Guid accountId)
=> Connection.Table<AccountCalendar>().Where(x => x.AccountId == accountId).OrderByDescending(a => a.IsPrimary).ToListAsync();
@@ -344,6 +349,10 @@ public class CalendarService : BaseDatabaseService, ICalendarService
return result;
}
/// <summary>
/// Gets attendees for a calendar item. For recurring event occurrences,
/// callers should pass the EventTrackingId which returns the parent's ID.
/// </summary>
public Task<List<CalendarEventAttendee>> GetAttendeesAsync(Guid calendarEventTrackingId)
=> Connection.Table<CalendarEventAttendee>().Where(x => x.CalendarItemId == calendarEventTrackingId).ToListAsync();
@@ -423,4 +432,28 @@ public class CalendarService : BaseDatabaseService, ICalendarService
}
}
}
/// <summary>
/// Gets reminders for a calendar item. For recurring event occurrences,
/// callers should pass the EventTrackingId which returns the parent's ID.
/// </summary>
public Task<List<Reminder>> GetRemindersAsync(Guid calendarItemId)
=> Connection.Table<Reminder>().Where(r => r.CalendarItemId == calendarItemId).ToListAsync();
public async Task SaveRemindersAsync(Guid calendarItemId, List<Reminder> reminders)
{
await Connection.RunInTransactionAsync((connection) =>
{
// Clear existing reminders for this calendar item
connection.Execute(
"DELETE FROM Reminder WHERE CalendarItemId = ?",
calendarItemId);
// Insert new reminders if any
if (reminders != null && reminders.Count > 0)
{
connection.InsertAll(reminders, typeof(Reminder));
}
});
}
}