Beispiel #1
0
        public async Task <IdentityMessageModel> GenerateRecoveryEmail(UserLanguageEnum letterLanguage, string email,
                                                                       string verificationToken, FrontClientType frontClient)
        {
            string mainUrl = "";

            if (frontClient == FrontClientType.AdminPanel)
            {
                mainUrl = _baseAdminUrl;
            }
            else if (frontClient == FrontClientType.WebClient)
            {
                mainUrl = _baseClientUrl;
            }
            else
            {
                throw new Exception("Unsupported front_client_type");
            }

            var confirmationLink = $"{mainUrl}/account/recovery_password/{HttpUtility.UrlEncode(verificationToken)}/{HttpUtility.UrlEncode(email)}";
            var subject          = _emailContentBuilderManager.GetSubject(letterLanguage, LetterTypeEnum.RecoveryPassword);
            var letterParams     = new LetterTextParamsModel()
            {
                LetterLanguage = letterLanguage,
                TypeContact    = ContactTypeEnum.Email,
                LetterType     = LetterTypeEnum.RecoveryPassword,
                Params         = new Dictionary <string, string>()
                {
                    { "contact", email },
                    { "confirmationLink", confirmationLink }
                }
            };

            return(await BuildMessageResultModelAsync(letterParams, email, subject));
        }
Beispiel #2
0
 private async Task <IdentityMessageModel> BuildMessageResultModelAsync(LetterTextParamsModel letterParams, string contact,
                                                                        string subject)
 {
     return(new IdentityMessageModel()
     {
         Content = await _emailContentBuilderManager.GetContent(letterParams),
         Destinations = new List <string>()
         {
             contact
         },
         Subject = subject,
     });
 }
Beispiel #3
0
        public async Task <IdentityMessageModel> GenerateVerificationSms(UserLanguageEnum letterLanguage, string phone, string verificationToken)
        {
            var subject      = _smsContentBuilderManager.GetSubject(letterLanguage, LetterTypeEnum.ContactVerification);
            var letterParams = new LetterTextParamsModel()
            {
                LetterLanguage = letterLanguage,
                LetterType     = LetterTypeEnum.ContactVerification,
                TypeContact    = ContactTypeEnum.Phone,
                Params         = new Dictionary <string, string>()
                {
                    { "contact", phone },
                    { "confirmationLink", verificationToken }
                }
            };

            return(await BuildMessageResultModelAsync(letterParams, phone, subject));
        }
Beispiel #4
0
        public async Task <IdentityMessageModel> GenerateSuppotEmail(UserLanguageEnum letterLanguage, string email, string question,
                                                                     string answer)
        {
            var subject      = _emailContentBuilderManager.GetSubject(letterLanguage, LetterTypeEnum.SupportService);
            var letterParams = new LetterTextParamsModel()
            {
                LetterLanguage = letterLanguage,
                TypeContact    = ContactTypeEnum.Email,
                LetterType     = LetterTypeEnum.SupportService,
                Params         = new Dictionary <string, string>()
                {
                    { "question", question },
                    { "answer", answer }
                }
            };

            return(await BuildMessageResultModelAsync(letterParams, email, subject));
        }
Beispiel #5
0
        public string GetText(LetterTextParamsModel letterParams)
        {
            var text = Texts.FirstOrDefault(x => x.LetterType == letterParams.LetterType &&
                                            x.LetterLanguage == letterParams.LetterLanguage &&
                                            x.TypeContact == letterParams.TypeContact)?.Text ?? "";

            foreach (var item in letterParams.Params)
            {
                var name = "{" + item.Key + "}";

                if (text.Contains(name))
                {
                    text = text.Replace(name, item.Value);
                }
            }

            return(text);
        }
Beispiel #6
0
        public async Task <IdentityMessageModel> GenerateVerificationEmail(UserLanguageEnum letterLanguage, string email,
                                                                           string verificationToken)
        {
            var confirmationLink = $"{_baseClientUrl}/account/confirm_email/{HttpUtility.UrlEncode(verificationToken)}/{HttpUtility.UrlEncode(email)}";
            var subject          = _emailContentBuilderManager.GetSubject(letterLanguage, LetterTypeEnum.ContactVerification);
            var letterParams     = new LetterTextParamsModel()
            {
                LetterLanguage = letterLanguage,
                TypeContact    = ContactTypeEnum.Email,
                LetterType     = LetterTypeEnum.ContactVerification,
                Params         = new Dictionary <string, string>()
                {
                    { "contact", email },
                    { "confirmationLink", confirmationLink }
                }
            };

            return(await BuildMessageResultModelAsync(letterParams, email, subject));
        }
Beispiel #7
0
 protected override string GetWrapper(LetterTextParamsModel letterParams)
 {
     return(GetText(letterParams));
 }
Beispiel #8
0
 // Used to build the overall structure of the letter (text with wrapper)
 protected abstract string GetWrapper(LetterTextParamsModel letterParams);
Beispiel #9
0
 // Get letter text based on the letter type, contact type (email, sms) and language
 protected virtual string GetText(LetterTextParamsModel letterParams)
 {
     return(_textLetterBuilderManager.GetText(letterParams));
 }
Beispiel #10
0
        public virtual Task <string> GetContent(LetterTextParamsModel letterParams)
        {
            var body = GetWrapper(letterParams);

            return(Task.FromResult(body));
        }
Beispiel #11
0
 protected override string GetWrapper(LetterTextParamsModel letterParams)
 {
     if (letterParams.LetterLanguage == UserLanguageEnum.English)
     {
         return(@"<html>
                     <head>
                       <style>
                         @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
                         @import url('https://fonts.googleapis.com/css2?family=Carter+One&display=swap');
                         body {
                           font-family: Poppins, sans-serif;
                         }
                         #outlook a {
                           padding: 0;
                         }
                         .ReadMsgBody {
                           width: 100%;
                         }
                         .ExternalClass {
                           width: 100%;
                         }
                         .ExternalClass,
                         .ExternalClass p,
                         .ExternalClass span,
                         .ExternalClass font,
                         .ExternalClass td,
                         .ExternalClass div {
                           line-height: 100%;
                         }
                         body,
                         table,
                         td,
                         a {
                           -webkit-text-size-adjust: 100%;
                           -ms-text-size-adjust: 100%;
                         }
                         table,
                         td {
                           mso-table-lspace: 0pt;
                           mso-table-rspace: 0pt;
                         }
                         img {
                           -ms-interpolation-mode: bicubic;
                         }
                         body {
                           height: 100% !important;
                           margin: 0;
                           padding: 0;
                           width: 100% !important;
                         }
                         img {
                           border: 0;
                           height: auto;
                           line-height: 100%;
                           outline: none;
                           text-decoration: none;
                         } 
                         table {
                           border-collapse: collapse !important;
                         }
                         @media screen and(max-width: 600px)
                         {
                           td[class='logo'] {
                             padding: 6px 0 2px 0! important;
                           }
                           td[class='logo'] img {
                             width: 62px !important;
                           }
                           table[class='wrapper'] {
                             width: 100% !important;
                           }
                           td[class='mobile-text-hi1'] {
                             padding: 19px 0 0 0 !important;
                             font-size: 18px !important;
                             line-height: 27px !important;
                           }
                           td[class='mobile-text-hi2'] {
                             padding: 0 0 33px 0 !important;
                             font-size: 18px !important;
                             line-height: 27px!important;
                           }
                           td[class='card'] {
                             padding: 23px 16px 26px 16px !important;
                           }
                           td[class='mobile-title'] {
                             padding: 33px 10px 6px 10px !important;
                             font-size: 24px !important;
                             line-height: 36px !important;
                           }
                           td[class='mobile-subtitle'] {
                             padding: 6px 25px 10px 25px !important;
                             font-size: 14px !important;
                             line-height: 21px !important;
                           }
                           td[class='mobile-button'] {
                             padding: 19px 0 46px 0 !important;
                           }
                           td[class='mobile-button'] a {
                             font-size: 14px !important;
                             line-height: 21px !important;
                             border-top: 15px solid #FFA800 !important;
                             border-bottom: 15px solid #FFA800 !important;
                             border-right: 48px solid #FFA800 !important;
                             border-left: 48px solid #FFA800 !important;
                           }
                           td[class='mobile-question'] {
                             padding: 73px 0 12px 0 !important;
                             font-size: 16px !important;
                             line-height: 24px !important;
                           }
                           td[class='mobile-response'] {
                             padding: 2px 0 10px 0 !important;
                             font-size: 16px !important;
                             line-height: 24px !important;
                           }
                           td[class='mobile-link'] {
                             padding: 25px 0 4px 0 !important;
                           }
                         }
                       </style>
                     </head>
                     <body style='margin: 0; padding: 0; background-color: #eeeeee;'>
                       <table border='0' cellpadding='0' cellspacing='0' width='100%' style='table-layout: fixed;'>
                         <tr>
                           <td align='center' bgcolor='#eeeeee'>
                             <table border='0' cellpadding='0' cellspacing='0' width='600' class='wrapper'>
                               <tr>
                                 <td bgcolor='#ffffff' style='padding: 23px 56px 26px 56px;' class='card'>
                                   <table border='0' cellpadding='0' cellspacing='0' width='100%'>
                                     <tr>
                                       <td align='center' class='logo'>
                                         <img src='" + _baseUrl + _routeGetFile + mainlogo + @"' alt='logo' width='74' border='0' style='display: block;'/>
                                       </td>
                                     </tr>
                                     <tr>" + GetText(letterParams) + @"</tr>   
                                     <tr>
                                       <td align='center' style='padding: 14px 0 3px 0; color: #000000; font-family: Poppins, Arial, sans-serif; font-weight: 700; font-size: 18px; line-height: 27px;' class='mobile-question'>
                                         Didn’t request this email?
                                       </td>
                                     </tr>
                                     <tr>
                                       <td align='center' style='padding: 2px 25px 5px 25px; color: #000000; font-family: Poppins, Arial, sans-serif; font-weight: 500; font-size: 14px; line-height: 21px;' class='mobile-response'>
                                           No worries! Your address may have been entered by mistake.
                                           If you ignore or delete this email, nothing further will happen.
                                       </td>
                                     </tr>
                                     <tr>
                                       <td align='center' style='padding: 14px 0 4px 0; color: #000000; font-family: Carter One, cursive; font-weight: normal; font-size: 18px; line-height: 27px;' class='mobile-link'>
                                         <a href='#' style='color: #FFA800; text-decoration: none;'>(Shop title)</a>
                                       </td>
                                     </tr>
                                     <tr>
                                       <td align='center' style='padding: 2px 0 0 0; color: #222222; font-family: Poppins, Arial, sans-serif; font-weight: 500; font-size: 12px; line-height: 18px;'>
                                         © (Shop title) by<strong> Igor Shevchenko.</strong>
                                       </td>
                                     </tr>
                                     <tr>
                                       <td align='center' style='padding: 0 0 2px 0; color: #222222; font-family: Poppins, Arial, sans-serif; font-weight: 500; font-size: 12px; line-height: 18px;'>
                                         All Rights Reserved.
                                       </td>
                                     </tr>
                                   </table>
                                 </td>
                               </tr>
                             </table>
                           </td>
                         </tr>
                       </table>
                     </body>
                 </html>");
     }
     else
     {
         return(@"<html>
                     <head>
                       <style>
                         @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
                         @import url('https://fonts.googleapis.com/css2?family=Carter+One&display=swap');
                         body {
                           font-family: Poppins, sans-serif;
                         }
                         #outlook a {
                           padding: 0;
                         }
                         .ReadMsgBody {
                           width: 100%;
                         }
                         .ExternalClass {
                           width: 100%;
                         }
                         .ExternalClass,
                         .ExternalClass p,
                         .ExternalClass span,
                         .ExternalClass font,
                         .ExternalClass td,
                         .ExternalClass div {
                           line-height: 100%;
                         }
                         body,
                         table,
                         td,
                         a {
                           -webkit-text-size-adjust: 100%;
                           -ms-text-size-adjust: 100%;
                         }
                         table,
                         td {
                           mso-table-lspace: 0pt;
                           mso-table-rspace: 0pt;
                         }
                         img {
                           -ms-interpolation-mode: bicubic;
                         }
                         body {
                           height: 100% !important;
                           margin: 0;
                           padding: 0;
                           width: 100% !important;
                         }
                         img {
                           border: 0;
                           height: auto;
                           line-height: 100%;
                           outline: none;
                           text-decoration: none;
                         } 
                         table {
                           border-collapse: collapse !important;
                         }
                         @media screen and(max-width: 600px)
                         {
                           td[class='logo'] {
                             padding: 6px 0 2px 0! important;
                           }
                           td[class='logo'] img {
                             width: 62px !important;
                           }
                           table[class='wrapper'] {
                             width: 100% !important;
                           }
                           td[class='mobile-text-hi1'] {
                             padding: 19px 0 0 0 !important;
                             font-size: 18px !important;
                             line-height: 27px !important;
                           }
                           td[class='mobile-text-hi2'] {
                             padding: 0 0 33px 0 !important;
                             font-size: 18px !important;
                             line-height: 27px!important;
                           }
                           td[class='card'] {
                             padding: 23px 16px 26px 16px !important;
                           }
                           td[class='mobile-title'] {
                             padding: 33px 10px 6px 10px !important;
                             font-size: 24px !important;
                             line-height: 36px !important;
                           }
                           td[class='mobile-subtitle'] {
                             padding: 6px 25px 10px 25px !important;
                             font-size: 14px !important;
                             line-height: 21px !important;
                           }
                           td[class='mobile-button'] {
                             padding: 19px 0 46px 0 !important;
                           }
                           td[class='mobile-button'] a {
                             font-size: 14px !important;
                             line-height: 21px !important;
                             border-top: 15px solid #FFA800 !important;
                             border-bottom: 15px solid #FFA800 !important;
                             border-right: 48px solid #FFA800 !important;
                             border-left: 48px solid #FFA800 !important;
                           }
                           td[class='mobile-question'] {
                             padding: 73px 0 12px 0 !important;
                             font-size: 16px !important;
                             line-height: 24px !important;
                           }
                           td[class='mobile-response'] {
                             padding: 2px 0 10px 0 !important;
                             font-size: 16px !important;
                             line-height: 24px !important;
                           }
                           td[class='mobile-link'] {
                             padding: 25px 0 4px 0 !important;
                           }
                         }
                       </style>
                     </head>
                     <body style='margin: 0; padding: 0; background-color: #eeeeee;'>
                       <table border='0' cellpadding='0' cellspacing='0' width='100%' style='table-layout: fixed;'>
                         <tr>
                           <td align='center' bgcolor='#eeeeee'>
                             <table border='0' cellpadding='0' cellspacing='0' width='600' class='wrapper'>
                               <tr>
                                 <td bgcolor='#ffffff' style='padding: 23px 56px 26px 56px;' class='card'>
                                   <table border='0' cellpadding='0' cellspacing='0' width='100%'>
                                     <tr>
                                       <td align='center' class='logo'>
                                         <img src='" + _baseUrl + _routeGetFile + mainlogo + @"' alt='logo' width='74' border='0' style='display: block;'/>
                                       </td>
                                     </tr>
                                     <tr>" + GetText(letterParams) + @"</tr>   
                                     <tr>
                                       <td align='center' style='padding: 14px 0 3px 0; color: #000000; font-family: Poppins, Arial, sans-serif; font-weight: 700; font-size: 18px; line-height: 27px;' class='mobile-question'>
                                         Не знаете, что это за письмо?
                                       </td>
                                     </tr>
                                     <tr>
                                       <td align='center' style='padding: 2px 25px 5px 25px; color: #000000; font-family: Poppins, Arial, sans-serif; font-weight: 500; font-size: 14px; line-height: 21px;' class='mobile-response'>
                                           Не беспокойся! Возможно, вы получили этот email по ошибке.
                                           Если вы проигнорируете или удалите это письмо, больше ничего не произойдет.
                                       </td>
                                     </tr>
                                     <tr>
                                       <td align='center' style='padding: 14px 0 4px 0; color: #000000; font-family: Carter One, cursive; font-weight: normal; font-size: 18px; line-height: 27px;' class='mobile-link'>
                                         <a href='#' style='color: #FFA800; text-decoration: none;'>(Название магазина)</a>
                                       </td>
                                     </tr>
                                     <tr>
                                       <td align='center' style='padding: 2px 0 0 0; color: #222222; font-family: Poppins, Arial, sans-serif; font-weight: 500; font-size: 12px; line-height: 18px;'>
                                         ©(Название магазина) от<strong> Igor Shevchenko.</strong>
                                       </td>
                                     </tr>
                                     <tr>
                                       <td align='center' style='padding: 0 0 2px 0; color: #222222; font-family: Poppins, Arial, sans-serif; font-weight: 500; font-size: 12px; line-height: 18px;'>
                                         Все права защищены.
                                       </td>
                                     </tr>
                                   </table>
                                 </td>
                               </tr>
                             </table>
                           </td>
                         </tr>
                       </table>
                     </body>
                 </html>");
     }
 }