Exemplo n.º 1
0
        public async Task <IActionResult> SendContactMessage(ContactSendMessageViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var emailSentResult = await _iEmailSenderManager.ContactSendEmailToAdmin(model);

                    if (emailSentResult.Success)
                    {
                        _result = Result.Ok(MessageHelper.SentMessage);
                    }
                    else
                    {
                        _result = Result.Fail(MessageHelper.SentMessageFail);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(LoggerMessageHelper.FormateMessageForException(ex, "SendContactMessage"));
                _result = Result.Fail(MessageHelper.SentMessageFail);
            }
            var json = new { success = _result.Success, errortype = _result.ErrorType, error = _result.Error };

            return(new JsonResult(json));
        }
Exemplo n.º 2
0
        public static string GetContactSendMessageEmailTemplate(string title = "City Glass - Contact Us!", ContactSendMessageViewModel contactSendMessageViewModel = null)
        {
            string html = string.Empty;

            if (contactSendMessageViewModel != null)
            {
                html += "<div style='vertical-align: top; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto;' valign='top'>";
                html += "<div width='100%' cellpadding='0' cellspacing='0' style='font-family: Montserrat; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;' bgcolor='#fff'>";
                html += "<table align='center' width='100%' cellpadding='0' cellspacing='0' style='box-sizing: border-box; font-family: Montserrat; margin: 0 auto; padding: 0;' bgcolor='#FFFFFF'>";
                html += "<tbody>";
                html += "<tr>";
                html += "<td style='box-sizing: border-box; font-family: Montserrat; padding: 35px; word-break: break-word;'>";

                html += "<table width='100%' border='0' cellspacing='0' cellpadding='0' style='box-sizing: border-box; font-family: Montserrat;'>";
                html += "<tbody>";

                //start

                html += "<tr style='box-sizing: border-box; font-family: Montserrat; word-break: break-word; padding-bottom: 20px; display: inline-block;'>";

                html += "<td width='100%' style='box-sizing: border-box;'>";
                html += "<div style='padding: 0px 10px;'>";
                html += "<h4 style='line-height: 30px; font-size: 20px;'>";
                html += $"Message Category : {contactSendMessageViewModel.MessageCategory}";
                html += "</h4>";
                html += "<h5 style='line-height: 28px; font-size: 18px; margin-bottom: 5px;'>";
                html += $"Email : {contactSendMessageViewModel.ContactEmail}";
                html += "</h5>";
                html += "<h5 style='line-height: 18px; font-size: 16px; font-weight: 400; margin-bottom: 5px;'>";
                html += $"Name : {contactSendMessageViewModel.ContactName}";
                html += "</h5>";
                html += "<h5 style='line-height: 18px; font-size: 16px; font-weight: 400; margin-bottom: 5px;'>";
                html += $"Phone : {contactSendMessageViewModel.ContactPhone}";
                html += "</h5>";
                html += "<h5 style='line-height: 18px; font-size: 16px; font-weight: 400; margin-bottom: 5px;'>";
                html += $"Subject : {contactSendMessageViewModel.ContactSubject}";
                html += "</h5>";
                html += "<h5 style='line-height: 18px; font-size: 16px; font-weight: 400; margin-bottom: 5px;'>";
                html += $"Message : {contactSendMessageViewModel.ContactMessage}";
                html += "</h5>";
                html += "</div>";
                html += "</td>";

                html += "</tr>";

                //end


                html += "</tbody>";
                html += "</table><table style='border-top-color: #EDEFF2; border-top-style: solid; border-top-width: 1px; box-sizing: border-box; font-family: Montserrat; margin-top: 25px; padding-top: 25px;'><tbody><tr><td style='box-sizing: border-box; font-family: Montserrat; word-break: break-word;'><p style='box-sizing: border-box; color: #74787E; font-family: Montserrat; font-size: 12px; line-height: 1.5em; margin-top: 0;' align='left'> Do not reply to this email address. Emails sent to this address will not receive a response.</p></td></tr></tbody></table>";
                html += "</td>";
                html += "</tr>";
                html += "</tbody>";
                html += "</table>";
                html += "</div>";
                html += "</div>";
            }

            return(html);
        }
Exemplo n.º 3
0
        public async Task <EmailSentResult> ContactSendEmailToAdmin(ContactSendMessageViewModel contactSendMessageViewModel)
        {
            try
            {
                string emailTitle    = $"City Glass - Contact Us!";
                string emailSubject  = emailTitle;
                string emailTemplate = EmailTemplateHelper.GetContactSendMessageEmailTemplate(emailTitle, contactSendMessageViewModel: contactSendMessageViewModel);

                string emailAddressDisplayName = _cityGlassContactUsConfig.EmailAddressDisplayName;
                string emailAddress            = _cityGlassContactUsConfig.EmailAddress;

                if (contactSendMessageViewModel.MessageCategoryValue == MessageCategoryValueEnum.CommercialGlassWindowsAndDoors.ToString())
                {
                    emailAddress = _cityGlassContactUsConfig.CommercialGlassWindowsAndDoors;
                }
                else if (contactSendMessageViewModel.MessageCategoryValue == MessageCategoryValueEnum.LargeScaleGlassAndMirrorBids.ToString())
                {
                    emailAddress = _cityGlassContactUsConfig.LargeScaleGlassAndMirrorBids;
                }
                else if (contactSendMessageViewModel.MessageCategoryValue == MessageCategoryValueEnum.MirrorShowerGlassInstallation.ToString())
                {
                    emailAddress = _cityGlassContactUsConfig.MirrorShowerGlassInstallation;
                }
                else if (contactSendMessageViewModel.MessageCategoryValue == MessageCategoryValueEnum.ResidentialGlassWindowsAndDoors.ToString())
                {
                    emailAddress = _cityGlassContactUsConfig.ResidentialGlassWindowsAndDoors;
                }
                else if (contactSendMessageViewModel.MessageCategoryValue == MessageCategoryValueEnum.TheOnlineEstimates.ToString())
                {
                    emailAddress = _cityGlassContactUsConfig.TheOnlineEstimates;
                }

                EmailMessage emailMessage = new EmailMessage();
                emailMessage.ReceiverName  = emailAddressDisplayName;
                emailMessage.ReceiverEmail = emailAddress;
                emailMessage.Subject       = emailSubject;
                emailMessage.IsHtml        = true;
                emailMessage.Body          = emailTemplate;

                var emailSentResult = await SendEmailMessage(emailMessage, "contactUsUser");

                if (!string.IsNullOrEmpty(_cityGlassEmailConfig.TestEmailAddress))
                {
                    string[] testEmailAddressList = _cityGlassEmailConfig.TestEmailAddress.Split(",");
                    foreach (var testEmailAddress in testEmailAddressList)
                    {
                        string[]     testEmailAddressReceiverEmailAndNameList = testEmailAddress.Split("_");
                        EmailMessage testEmailMessage = new EmailMessage();
                        testEmailMessage.ReceiverName  = testEmailAddressReceiverEmailAndNameList[0].ToString();
                        testEmailMessage.ReceiverEmail = testEmailAddressReceiverEmailAndNameList[1].ToString();
                        testEmailMessage.Subject       = emailSubject;
                        testEmailMessage.IsHtml        = true;
                        testEmailMessage.Body          = emailTemplate;

                        var testEmailSentResult = await SendEmailMessage(testEmailMessage, "contactUsUser");
                    }
                }

                return(emailSentResult);
            }
            catch (Exception ex)
            {
                return(new EmailSentResult {
                    Success = false, Ex = ex
                });
            }
        }
Exemplo n.º 4
0
        public static string GetContactSendMessageSmsTemplate(string title = "Contact Us!", ContactSendMessageViewModel contactSendMessageViewModel = null)
        {
            string template = $"{title} - Subject: {contactSendMessageViewModel.ContactSubject} , Message: {contactSendMessageViewModel.ContactMessage}";

            return(template);
        }