Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Commit

Permalink
feat(back-end): Add HTML email template for NewActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosPavajeau committed Mar 19, 2021
1 parent 30c0dbb commit b7ac44a
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 74 deletions.
21 changes: 15 additions & 6 deletions Kaizen/DomainEvents/Handlers/OnSavedActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,33 @@ public class Handler : INotificationHandler<DomainEventNotification<SavedActivit
private readonly IHubContext<ActivityHub> _hubContext;
private readonly IMapper _mapper;
private readonly IMailService _mailService;
private readonly IMailTemplate _mailTemplate;
private readonly IActivitiesRepository _activitiesRepository;
private readonly IClientsRepository _clientsRepository;
private readonly IUnitWork _unitWork;

public Handler(IHubContext<ActivityHub> hubContext, IMapper mapper, IMailService mailService, IActivitiesRepository activitiesRepository, IClientsRepository clientsRepository, IUnitWork unitWork)
public Handler(IHubContext<ActivityHub> hubContext, IMapper mapper, IMailService mailService,
IMailTemplate mailTemplate,
IActivitiesRepository activitiesRepository, IClientsRepository clientsRepository, IUnitWork unitWork)
{
_hubContext = hubContext;
_mapper = mapper;
_mailService = mailService;
_mailTemplate = mailTemplate;
_activitiesRepository = activitiesRepository;
_clientsRepository = clientsRepository;
_unitWork = unitWork;
}

public async Task Handle(DomainEventNotification<SavedActivity> notification, CancellationToken cancellationToken)
public async Task Handle(DomainEventNotification<SavedActivity> notification,
CancellationToken cancellationToken)
{
Activity activity = notification.DomainEvent.Activity;

await _activitiesRepository.ScheduleActivities(activity);
await NotifyNewActivityRegister(activity, cancellationToken);
await SendNotificationEmail(activity);
await UpdateClientState(activity);

}

private async Task NotifyNewActivityRegister(Activity activity, CancellationToken cancellationToken)
Expand All @@ -53,14 +57,19 @@ private async Task NotifyNewActivityRegister(Activity activity, CancellationToke
private async Task SendNotificationEmail(Activity activity)
{
Client client = activity.Client;
await _mailService.SendEmailAsync(client.User.Email, "Actividad pendiente", $"Estimado {client.LastName} {client.FirstName} hemos agendado " +
$"la actividad N° {activity.Code} para el día {activity.Date} para aplicar los servicios solicitados por usted");

string emailMessage = _mailTemplate.LoadTemplate("NewActivity.html",
$"{client.LastName} {client.FirstName}", activity.Date.ToString("yyyy/MM/dd hh:mm tt"));

await _mailService.SendEmailAsync(client.User.Email, "Solicitud de servicios", emailMessage, true);
}

private async Task UpdateClientState(Activity activity)
{
Client client = activity.Client;
client.State = (activity.Periodicity == PeriodicityType.Casual) ? ClientState.Casual : ClientState.Active;
client.State = (activity.Periodicity == PeriodicityType.Casual)
? ClientState.Casual
: ClientState.Active;

_clientsRepository.Update(client);

Expand Down
113 changes: 113 additions & 0 deletions Kaizen/EmailTemplates/NewActivity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap"
rel="stylesheet"
/>
<title>Nueva actividad</title>
<style>
* {
margin: 0;
padding: 0;
font-family: "Roboto", Arial, Helvetica, sans-serif;
}

span {
max-width: 780px;
}
</style>
</head>
<body style="display: block; margin: 0; padding: 0;">
<div
style="
background-color: #0039ac;
height: 30px;
max-width: 800px;
display: block;
margin: 0 auto;
"
></div>
<h1
style="
text-align: center;
font-size: 30px;
font-family: 'Roboto', Arial, Helvetica, sans-serif;
margin-top: 17px;
margin-bottom: 17px;
"
>
Respuesta de solicitud de servicios
</h1>
<div
style="margin: 0 auto; align-items: center; width: 150px; height: 150px;"
>
<img
src="https://i.imgur.com/aVtcOk3.png"
alt="Logo ecolplag"
width="150"
height="150"
/>
</div>
<span
style="
font-size: 15px;
font-family: 'Roboto', Arial, Helvetica, sans-serif;
display: block;
padding: 15px 35px;
text-align: center;
margin: 7px auto 0;
"
>
Estimado {1}, hemos aceptado su solicitud de nuestros servicios y hemos agendado las actividades a realizar.
</span>
<span
style="
font-size: 15px;
font-family: 'Roboto', Arial, Helvetica, sans-serif;
display: block;
margin: 0 auto;
padding: 10px 35px;
text-align: center;
"
>
Su primera actividad sera en la fecha y hora {2} donde aplicaremos los servicios solicitados por usted.
</span>
<span
style="
font-size: 15px;
font-family: 'Roboto', Arial, Helvetica, sans-serif;
display: block;
margin: 0 auto;
padding: 15px 35px;
text-align: center;
"
>
<strong>
Agradecemos que nos escogieras.
</strong>
</span>
<span
style="
text-align: center;
display: block;
margin: 0 auto 7px;
"
>
<small>
<strong>&copy; Ecolplag S.A.S</strong>
</small>
</span>
<div
style="
background-color: #0039ac;
height: 30px;
max-width: 800px;
display: block;
margin: 1.5rem auto 0;
"
></div>
</body>
</html>
134 changes: 66 additions & 68 deletions Kaizen/EmailTemplates/NewClient.html
Original file line number Diff line number Diff line change
@@ -1,88 +1,88 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap"
rel="stylesheet"
/>
<title>Bienvenido</title>
<style>
* {
margin: 0;
padding: 0;
font-family: "Roboto", Arial, Helvetica, sans-serif;
}
span {
max-width: 780px;
}
</style>
</head>
<body style="display: block; margin: 0; padding: 0;">
<div
style="
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap"
rel="stylesheet"
/>
<title>Bienvenido</title>
<style>
* {
margin: 0;
padding: 0;
font-family: "Roboto", Arial, Helvetica, sans-serif;
}

span {
max-width: 780px;
}
</style>
</head>
<body style="display: block; margin: 0; padding: 0;">
<div
style="
background-color: #0039ac;
height: 30px;
max-width: 800px;
display: block;
margin: 0 auto;
"
></div>
<h1
style="
></div>
<h1
style="
text-align: center;
font-size: 30px;
font-family: 'Roboto', Arial, Helvetica, sans-serif;
margin-top: 17px;
margin-bottom: 17px;
"
>
Bienvenido a nuestra empresa
</h1>
<div
style="margin: 0 auto; align-items: center; width: 150px; height: 150px;"
>
<img
src="https://i.imgur.com/aVtcOk3.png"
alt="Logo ecolplag"
width="150"
height="150"
/>
</div>
<span
style="
>
Bienvenido a nuestra empresa
</h1>
<div
style="margin: 0 auto; align-items: center; width: 150px; height: 150px;"
>
<img
src="https://i.imgur.com/aVtcOk3.png"
alt="Logo ecolplag"
width="150"
height="150"
/>
</div>
<span
style="
font-size: 15px;
font-family: 'Roboto', Arial, Helvetica, sans-serif;
display: block;
margin: 0 auto;
padding: 15px 35px;
text-align: center;
margin-top: 7px;
margin: 7px auto 0;
"
>
>
Bienvenido señor {1} usted acaba de registrarse como cliente en nuestra
empresa con el nombre comercial de {2}. Úbicado en la ciudad de {3} barrio
{4} calle {5}.
</span>
<span
style="
<span
style="
font-size: 15px;
font-family: 'Roboto', Arial, Helvetica, sans-serif;
display: block;
margin: 0 auto;
padding: 15px 35px;
text-align: center;
"
>
>
Hasta el momento hemos recibido su solicitud para ser parte de nuestra
empresa, te responderemos en poco tiempo si fuiste aceptado como uno de
nuestros clientes. Pero puedes confirmar tu correo electronico para
asegurarnos de que eres una persona real.
</span>
<a
href="{6}"
style="
<a
href="{6}"
style="
display: block;
margin: 0 auto;
text-align: center;
Expand All @@ -99,46 +99,44 @@
margin-top: 5px;
margin-bottom: 7px;
"
target="blank"
>
Confirmar correo
</a>
<span
style="
target="blank"
>
Confirmar correo
</a>
<span
style="
font-size: 15px;
font-family: 'Roboto', Arial, Helvetica, sans-serif;
display: block;
margin: 0 auto;
padding: 15px 35px;
text-align: center;
"
>
>
<strong>
Podrás reservar nuestros servicios cuando seas aceptado como cliente y
confirmes tu correo electronico.
</strong>
</span>
<span
style="
<span
style="
text-align: center;
margin: 0 auto;
display: block;
margin-bottom: 7px;
margin: 0 auto 7px;
"
>
>
<small>
<strong>Ecolplag S.A.S</strong>
<strong>&copy; Ecolplag S.A.S</strong>
</small>
</span>
<div
style="
<div
style="
background-color: #0039ac;
height: 30px;
max-width: 800px;
display: block;
margin: 0 auto;
margin-top: 1.5rem;
margin: 1.5rem auto 0;
"
></div>
</body>
></div>
</body>
</html>

0 comments on commit b7ac44a

Please sign in to comment.