Ejemplo n.º 1
0
        public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
        {
            var user = await _userReadRepository.GetByEmailAsync(request.Email);

            if (user == null)
            {
                return(new Response().AddError("Email is not registered"));
            }

            var newCode = _userWriteRepository.GenerateVerificationCode();

            user.UpdateChangePasswordCode(newCode);
            await _uow.CommitAsync();

            var emailSubject = "Código de Verificação";

            var emailBody = "<tr>" +
                            "<tr>" +
                            "<td align = \"center\" valign = \"middle\" width = \"100%\" style = \"font-family: Arial, sans-serif, 'Lato'; color: #585858; font-size: 22px; line-height: 1; padding-top: 48px;\" >" +
                            $"Olá, {user.Name}" +
                            "</td>" +
                            "</tr>" +
                            "<tr>" +
                            "<td align = \"center\" valign = \"middle\" width = \"100%\" style = \"font-family: Arial, sans-serif, 'Lato'; font-size: 32px; line-height: 1; padding-top: 35px;\" >" +
                            "Aqui está seu código de verificação para a troca de senha: " +
                            "</td>" +
                            "</tr>" +
                            "</tr>" +
                            "<tr>" +
                            "<td align=\"center\" width=\"100%\" style =\"font-family: Arial, sans-serif, 'Lato'; color: #000000; font-size: 42px; line-height: 1; padding-top: 0px;\">" +
                            $"{newCode}" +
                            "</td>" +
                            "</tr>";

            List <string> emails = new List <string>();

            emails.Add(user.Email);

            await _mediator.Publish(new Notification(emailSubject, emailBody, emails));

            return(new Response());
        }