Exemplo n.º 1
0
        public EmailViewModel GetEmailViewModelFromGeneralEmail(string emailAppSettingNodeIdKey)
        {
            var emailViewModel = new EmailViewModel();

            if (emailAppSettingNodeIdKey.IsNullOrWhiteSpace())
            {
                return(emailViewModel);
            }

            var emailContent = NodeUtils.GetContentFromAppSettingKey(emailAppSettingNodeIdKey);

            if (emailContent == null)
            {
                return(emailViewModel);
            }

            emailViewModel.BaseUriString = UrlUtils.GetBaseUri() != null
                ? UrlUtils.GetBaseUri().ToString()
                : String.Empty;

            emailViewModel.EmailTitle      = emailContent.GetPropertyValue <string>(PropertyAliases.Email.EmailTitle);
            emailViewModel.Subject         = emailContent.GetPropertyValue <string>(PropertyAliases.Email.Subject);
            emailViewModel.FromDisplayName = emailContent.GetPropertyValue <string>(PropertyAliases.Email.FromDisplayName);
            emailViewModel.FromAddress     = emailContent.GetPropertyValue <string>(PropertyAliases.Email.FromAddress);

            var toAddresses = emailContent.GetPropertyValue <string>(PropertyAliases.Email.ToAddress);

            emailViewModel.ToAddresses = GetToAddressesFromAddressString(toAddresses);
            emailViewModel.CopyTitle   = emailContent.GetPropertyValue <string>(PropertyAliases.Email.CopyTitle);

            var copy = emailContent.GetPropertyValue <IHtmlString>(PropertyAliases.Email.Copy);

            emailViewModel.Copy = !copy.IsNullOrWhiteSpace()
                ? new HtmlString(copy.ToString().PrependRelativeHrefsWithBaseUri(emailViewModel.BaseUriString))
                : new HtmlString(String.Empty);

            return(emailViewModel);
        }