From 6a6cfedb9965d73a2133b46170ca9cf1a17557f9 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Thu, 29 Dec 2022 13:43:51 -0500 Subject: [PATCH] Added message templates as constants --- src/Constants/MessageTemplates.cs | 20 ++++++++++++++++ ...intmentCancellationService.Notification.cs | 12 +++++----- .../AppointmentReminders/ReminderJob.cs | 4 +--- .../AppointmentInformationSendingService.cs | 24 +++++++------------ src/GlobalUsings.cs | 1 + 5 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 src/Constants/MessageTemplates.cs diff --git a/src/Constants/MessageTemplates.cs b/src/Constants/MessageTemplates.cs new file mode 100644 index 00000000..ff88bd74 --- /dev/null +++ b/src/Constants/MessageTemplates.cs @@ -0,0 +1,20 @@ +namespace DentallApp.Constants; + +public class MessageTemplates +{ + public const string AppointmentCancellationMessageTemplate = + "Estimado usuario {0}, su cita agendada en el consultorio odontológico {1} para el día {2} a las {3} ha sido cancelada por el siguiente motivo: {4}"; + + public const string AppointmentReminderMessageTemplate = + "Estimado usuario {0}, le recordamos que el día {1} a las {2} tiene una cita agendada en el consultorio {3} con el odontólogo {4}"; + + public const string AppointmentInformationMessageTemplate = + "Hola {0}, gracias por agendar una cita en el consultorio {1}. La información de su cita es:" + + "\n- Odontólogo: {2}" + + "\n- Consultorio: {3}" + + "\n- Servicio dental: {4}" + + "\n- Fecha de la cita: {5}" + + "\n- Hora de la cita: {6}" + + "\n{7}"; + +} diff --git a/src/Features/AppointmentCancellation/AppointmentCancellationService.Notification.cs b/src/Features/AppointmentCancellation/AppointmentCancellationService.Notification.cs index e54d0b52..533c2714 100644 --- a/src/Features/AppointmentCancellation/AppointmentCancellationService.Notification.cs +++ b/src/Features/AppointmentCancellation/AppointmentCancellationService.Notification.cs @@ -5,14 +5,14 @@ public partial class AppointmentCancellationService private async Task SendMessageAboutAppointmentCancellationAsync(IEnumerable appointmentsCanBeCancelled, string reason) { var businessName = EnvReader.Instance[AppSettings.BusinessName]; - var template = "Estimado usuario {0}, su cita agendada en el consultorio odontológico {1} para el día {2} a las {3} ha sido cancelada por el siguiente motivo: {4}"; foreach (var appointment in appointmentsCanBeCancelled) { - var msg = string.Format(template, appointment.PatientName, - businessName, - appointment.AppointmentDate.GetDateInSpanishFormat(), - appointment.StartHour.GetHourWithoutSeconds(), - reason); + var msg = string.Format(AppointmentCancellationMessageTemplate, + appointment.PatientName, + businessName, + appointment.AppointmentDate.GetDateInSpanishFormat(), + appointment.StartHour.GetHourWithoutSeconds(), + reason); await _instantMessaging.SendMessageAsync(appointment.PatientCellPhone, msg); } } diff --git a/src/Features/AppointmentReminders/ReminderJob.cs b/src/Features/AppointmentReminders/ReminderJob.cs index bb164751..ec73a6ae 100644 --- a/src/Features/AppointmentReminders/ReminderJob.cs +++ b/src/Features/AppointmentReminders/ReminderJob.cs @@ -6,8 +6,6 @@ public class ReminderJob : IJob private readonly AppSettings _settings; private readonly IServiceProvider _serviceProvider; private readonly IInstantMessaging _instantMessaging; - private const string TemplateMessage = - "Estimado usuario {0}, le recordamos que el día {1} a las {2} tiene una cita agendada en el consultorio {3} con el odontólogo {4}"; public ReminderJob(ILogger logger, AppSettings settings, @@ -30,7 +28,7 @@ public Task Execute(IJobExecutionContext context) var businessName = EnvReader.Instance[AppSettings.BusinessName]; foreach (var appointmentDto in scheduledAppointments) { - var message = string.Format(TemplateMessage, + var message = string.Format(AppointmentReminderMessageTemplate, appointmentDto.PatientName, appointmentDto.Date.GetDateInSpanishFormat(), appointmentDto.StartHour.GetHourWithoutSeconds(), diff --git a/src/Features/Appointments/Notification/AppointmentInformationSendingService.cs b/src/Features/Appointments/Notification/AppointmentInformationSendingService.cs index 366a40e7..0e128102 100644 --- a/src/Features/Appointments/Notification/AppointmentInformationSendingService.cs +++ b/src/Features/Appointments/Notification/AppointmentInformationSendingService.cs @@ -21,21 +21,15 @@ public async Task SendAppointmentInformationAsync(int appointmentId, Appointment appointmentInsertDto.RangeToPay ??= await _treatmentRepository.GetTreatmentWithRangeToPayAsync(appointmentInsertDto.GeneralTreatmentId); var businessName = EnvReader.Instance[AppSettings.BusinessName]; var info = await _appointmentRepository.GetAppointmentInformationAsync(appointmentId); - var template = "Hola {0}, gracias por agendar una cita en el consultorio {1}. La información de su cita es:" + - "\n- Odontólogo: {2}" + - "\n- Consultorio: {3}" + - "\n- Servicio dental: {4}" + - "\n- Fecha de la cita: {5}" + - "\n- Hora de la cita: {6}" + - "\n{7}"; - var msg = string.Format(template, info.PatientName, - businessName, - info.DentistName, - info.OfficeName, - info.DentalServiceName, - appointmentInsertDto.AppointmentDate.GetDateInSpanishFormat(), - appointmentInsertDto.StartHour.GetHourWithoutSeconds(), - appointmentInsertDto.RangeToPay?.ToString()); + var msg = string.Format(AppointmentInformationMessageTemplate, + info.PatientName, + businessName, + info.DentistName, + info.OfficeName, + info.DentalServiceName, + appointmentInsertDto.AppointmentDate.GetDateInSpanishFormat(), + appointmentInsertDto.StartHour.GetHourWithoutSeconds(), + appointmentInsertDto.RangeToPay?.ToString()); await _instantMessaging.SendMessageAsync(info.CellPhone, msg); } } diff --git a/src/GlobalUsings.cs b/src/GlobalUsings.cs index 1ecdd1a6..3e14a47b 100644 --- a/src/GlobalUsings.cs +++ b/src/GlobalUsings.cs @@ -85,6 +85,7 @@ global using DentallApp.Extensions; global using DentallApp.Constants; global using static DentallApp.Constants.ResponseMessages; +global using static DentallApp.Constants.MessageTemplates; global using System.Data; global using System.Text;