public async Task Handle(AppointmentCanceledEvent domainEvent, CancellationToken cancellationToken) { var appointment = await _appointmentRepository.GetSingleOrDefaultAsync( AppointmentSpecification.ById(domainEvent.AppointmentId)); if (domainEvent.RefundPayment && appointment.Transaction?.Status == TransactionStatus.Completed) { await _checkoutService.RefundAsync(appointment.Transaction, RefundType.PatientCredit, appointment.Transaction.Amount); } }
public async Task Handle(AppointmentCanceledEvent domainEvent, CancellationToken cancellationToken) { var appointment = await _appointmentRepository.GetSingleOrDefaultAsync( AppointmentSpecification.ById(domainEvent.AppointmentId)); var notifiedUser = await _userService.GetResponsibleUser(appointment.Patient.Id); var userPreference = await _preferenceRepository.LoadAsync <CommunicationPreference>(notifiedUser.Id); if (userPreference.ReceiveEmailAndCalendarReminders) { await SendEmail(appointment, notifiedUser); } if (userPreference.ReceiveSmsReminders) { await SendSms(appointment, notifiedUser); } }
public async Task Handle(AppointmentCreatedEvent appointmentCreatedEvent, CancellationToken cancellationToken) { _logger.LogInformation("{appointmentCreatedEvent}", appointmentCreatedEvent); var appointment = await _appointmentRepository.GetFirstOrDefaultAsync( AppointmentSpecification.ById(appointmentCreatedEvent.AppointmentId)); var notifiedUser = await _userService.GetResponsibleUser(appointment.Patient.Id); _logger.LogInformation($"Sending confirmation message to patient {notifiedUser.FullName}"); var userPreference = await _preferenceRepository.LoadAsync <CommunicationPreference>(notifiedUser.Id); if (userPreference.ReceiveEmailAndCalendarReminders) { await SendEmail(appointment, notifiedUser); } if (userPreference.ReceiveSmsReminders) { await SendSms(appointment, notifiedUser); } }
public async Task Handle(AppointmentRescheduledEvent domainEvent, CancellationToken cancellationToken) { var appointment = await _appointmentRepository.GetSingleOrDefaultAsync( AppointmentSpecification.ById(domainEvent.AppointmentId)); var notifiedUser = await _userService.GetResponsibleUser(appointment.Patient.Id); var values = await _appointmentService.GetTemplateValues(appointment); values["old_date_time"] = domainEvent.OldDateTime.ToString(); var userPreference = await _preferenceRepository.LoadAsync <CommunicationPreference>(notifiedUser.Id); if (userPreference.ReceiveEmailAndCalendarReminders) { await SendEmail(appointment, notifiedUser, values); } if (userPreference.ReceiveSmsReminders) { await SendSms(notifiedUser, values); } }