Skip to content

Commit

Permalink
Added message templates as constants
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDave1999 committed Dec 29, 2022
1 parent 8421b9e commit 6a6cfed
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
20 changes: 20 additions & 0 deletions src/Constants/MessageTemplates.cs
Original file line number Diff line number Diff line change
@@ -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}";

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ public partial class AppointmentCancellationService
private async Task SendMessageAboutAppointmentCancellationAsync(IEnumerable<AppointmentCancelDetailsDto> 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);
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/Features/AppointmentReminders/ReminderJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReminderJob> logger,
AppSettings settings,
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions src/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6a6cfed

Please sign in to comment.