コード例 #1
0
 public IActionResult Put([FromBody] List <SiteSetting> settings)
 {
     try
     {
         if (settings != null)
         {
             var result = _siteSettingRepository.UpdateSetting(settings);
             if (result != null)
             {
                 return(Ok(result));
             }
         }
         return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
     }
     catch (Exception ex)
     {
         _logger.LogError(string.Format("Error occured while creating a page layout, LayoutName: "), ex);
         return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
     }
 }
コード例 #2
0
        public SiteSettingInfo UpdateSettingInfo(SiteSettingInfo settingInfo)
        {
            var settings = _siteSettingRepository.GetSettings();
            var allAuthenticationTypes = SMTPAuthentication.GetSmtpAuthentications();

            settings.First(s => s.SettingName == nameof(SiteSettingInfo.SiteName)).SettingValue        = settingInfo.SiteName;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.SiteDescription)).SettingValue = settingInfo.SiteDescription;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.SiteAdminEmail)).SettingValue  = settingInfo.SiteAdminEmail;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.SiteRoot)).SettingValue        = settingInfo.SiteRoot;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.SiteHeaderTags)).SettingValue  = settingInfo.SiteHeaderTags;

            if (settingInfo.SiteLanguage != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.SiteLanguage)).SettingValue = settingInfo.SiteLanguage.CultureCode;
            }

            if (settingInfo.HomePage != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.HomePageId)).SettingValue = settingInfo.HomePage.Id.ToString();
            }
            if (settingInfo.LoginPage != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.LoginPageId)).SettingValue = settingInfo.LoginPage.Id.ToString();
            }
            if (settingInfo.RegistrationPage != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.RegistrationPageId)).SettingValue = settingInfo.RegistrationPage.Id.ToString();
            }
            if (settingInfo.RedirectAfterLogin != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.RedirectAfterLogin)).SettingValue = settingInfo.RedirectAfterLogin.Id.ToString();
            }
            if (settingInfo.RedirectAfterLogout != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.RedirectAfterLogout)).SettingValue = settingInfo.RedirectAfterLogout.Id.ToString();
            }

            settings.First(s => s.SettingName == nameof(SiteSettingInfo.SmtpServerAndPort)).SettingValue = settingInfo.SmtpServerAndPort;
            if (settingInfo.SmtpAuthentication != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.SmtpAuthentication)).SettingValue = allAuthenticationTypes.First(at => at.Id == settingInfo.SmtpAuthentication.Id).Name;
            }
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.SmtpEnableSSL)).SettingValue = settingInfo.SmtpEnableSSL.ToString().ToLower();
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.SmtpUsername)).SettingValue  = settingInfo.SmtpUsername;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.SmtpPassword)).SettingValue  = settingInfo.SmtpPassword;

            if (settingInfo.DefaultLayout != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.DefaultLayoutId)).SettingValue = settingInfo.DefaultLayout.Id.ToString();
            }
            if (settingInfo.DefaultAdminLayout != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.DefaultAdminLayoutId)).SettingValue = settingInfo.DefaultAdminLayout.Id.ToString();
            }
            if (settingInfo.DefaultTheme != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.DefaultTheme)).SettingValue = settingInfo.DefaultTheme.Id;
            }
            if (settingInfo.DefaultAdminTheme != null)
            {
                settings.First(s => s.SettingName == nameof(SiteSettingInfo.DefaultAdminTheme)).SettingValue = settingInfo.DefaultAdminTheme.Id;
            }

            settings.First(s => s.SettingName == nameof(SiteSettingInfo.RegistrationEnabled)).SettingValue   = settingInfo.RegistrationEnabled.ToString().ToLower();
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.EnableFacebookAuth)).SettingValue    = settingInfo.EnableFacebookAuth.ToString().ToLower();
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.EnableGoogleAuth)).SettingValue      = settingInfo.EnableGoogleAuth.ToString().ToLower();
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.EnableTwitterAuth)).SettingValue     = settingInfo.EnableTwitterAuth.ToString().ToLower();
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.FacebookAppId)).SettingValue         = settingInfo.FacebookAppId;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.FacebookAppSecret)).SettingValue     = settingInfo.FacebookAppSecret;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.GoogleClientId)).SettingValue        = settingInfo.GoogleClientId;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.GoogleClientSecret)).SettingValue    = settingInfo.GoogleClientSecret;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.TwitterConsumerKey)).SettingValue    = settingInfo.TwitterConsumerKey;
            settings.First(s => s.SettingName == nameof(SiteSettingInfo.TwitterConsumerSecret)).SettingValue = settingInfo.TwitterConsumerSecret;

            _siteSettingRepository.UpdateSetting(settings);

            return(GetSiteSetting());
        }