Clear ReminderSentAt when appointment is rescheduled

Edit POST now detects if ScheduledStartTime changed (via previousStart
comparison after AutoMapper merge) and nulls ReminderSentAt so the
background service will fire the reminder again at the new time.
Calendar drag-drop (UpdateEventTime) always clears ReminderSentAt since
rescheduling is its only purpose.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 16:03:58 -04:00
parent 2bf8871892
commit 07796b05c8
@@ -381,9 +381,15 @@ public class AppointmentsController : Controller
return View(dto);
}
// Map changes
// Map changes — capture old start before overwrite so we can detect a reschedule.
var previousStart = appointment.ScheduledStartTime;
_mapper.Map(dto, appointment);
// If the appointment was rescheduled, clear the reminder stamp so the background
// service will fire again at the new time.
if (appointment.ScheduledStartTime != previousStart)
appointment.ReminderSentAt = null;
// Update
await _unitOfWork.Appointments.UpdateAsync(appointment);
await _unitOfWork.CompleteAsync();
@@ -725,6 +731,8 @@ public class AppointmentsController : Controller
var duration = appointment.ScheduledEndTime - appointment.ScheduledStartTime;
appointment.ScheduledStartTime = start;
appointment.ScheduledEndTime = end;
// Drag-drop always changes the time — reset so the reminder fires at the new time.
appointment.ReminderSentAt = null;
await _unitOfWork.Appointments.UpdateAsync(appointment);
await _unitOfWork.CompleteAsync();