Exemplo n.º 1
0
        private async Task SendReminder(Appointment appointment, User notifiedUser)
        {
            var userPreference = await _preferenceRepository.LoadAsync <CommunicationPreference>(notifiedUser.Id);

            if (userPreference.ReceiveEmailAndCalendarReminders)
            {
                await SendReminderEmail(appointment, notifiedUser);
            }
            if (userPreference.ReceiveSmsReminders)
            {
                await SendReminderSms(appointment, notifiedUser);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 4
0
        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);
            }
        }