public async Task <SettingsModel> Get()
        {
            var allSettings = await _manageSettings.GetSettingsAsync();

            // Only sending limited settings, so more sensitive Keys aren't revealed.
            // May end up moving those to a ConfigurationModel later.
            var limitedSettings = new SettingsModel()
            {
                MainThemeColor      = allSettings.MainThemeColor,
                ShowNotice          = allSettings.ShowNotice,
                NoticeText          = allSettings.NoticeText,
                EnableNoticeMarquee = allSettings.EnableNoticeMarquee,
                ShowPhone           = allSettings.ShowPhone,
                PhoneNumber         = allSettings.PhoneNumber,
                Facebook            = allSettings.Facebook,
                LinkedIn            = allSettings.LinkedIn,
                Twitter             = allSettings.Twitter,
                GitHub            = allSettings.GitHub,
                Twitch            = allSettings.Twitch,
                YouTube           = allSettings.YouTube,
                GoogleAnalyticsID = allSettings.GoogleAnalyticsID,
                ReCaptchaKey      = allSettings.ReCaptchaKey
            };

            return(limitedSettings);
        }
示例#2
0
        public async Task <Task> SendContactFormEmailAsync(string senderName, string senderEmail, string senderPhone, string senderMessage, string subject = "Website Inquiry")
        {
            var message = FormattedBody(senderName, senderEmail, senderPhone, senderMessage);

            settingsModel = await _settings.GetSettingsAsync();

            return(Execute(settingsModel.SendGridKey, subject, message, senderEmail, settingsModel.EmailAddress));
        }
示例#3
0
        public async Task <bool?> PostForm(ContactFormModel contactFormModel)
        {
            try
            {
                var settings = await _manageSettings.GetSettingsAsync();

                var reCaptcha = new ReCaptcha();
                if (!reCaptcha.Validate(contactFormModel.ReCaptcha, settings.ReCaptchaSecretKey))
                {
                    return(false);
                }

                await new EmailSender(_manageSettings)
                .SendContactFormEmailAsync(contactFormModel.SenderName, contactFormModel.SenderEmail, contactFormModel.SenderPhone, contactFormModel.SenderMessage);

                return(true);
            }
            catch
            {
                return(false);
            }
        }