Пример #1
0
        public IActionResult GeneralSettings()
        {
            var tzList = _dateTimeResolver.GetTimeZones().Select(t => new SelectListItem
            {
                Text  = t.DisplayName,
                Value = t.Id
            }).ToList();

            var tmList = Utils.GetThemes().Select(t => new SelectListItem
            {
                Text  = t.Key,
                Value = t.Value
            }).ToList();

            var vm = new GeneralSettingsViewModel
            {
                LogoText                   = _blogConfig.GeneralSettings.LogoText,
                MetaKeyword                = _blogConfig.GeneralSettings.MetaKeyword,
                MetaDescription            = _blogConfig.GeneralSettings.MetaDescription,
                SiteTitle                  = _blogConfig.GeneralSettings.SiteTitle,
                Copyright                  = _blogConfig.GeneralSettings.Copyright,
                SideBarCustomizedHtmlPitch = _blogConfig.GeneralSettings.SideBarCustomizedHtmlPitch,
                FooterCustomizedHtmlPitch  = _blogConfig.GeneralSettings.FooterCustomizedHtmlPitch,
                BloggerName                = _blogConfig.BlogOwnerSettings.Name,
                BloggerDescription         = _blogConfig.BlogOwnerSettings.Description,
                BloggerShortDescription    = _blogConfig.BlogOwnerSettings.ShortDescription,
                SelectedTimeZoneId         = _blogConfig.GeneralSettings.TimeZoneId,
                SelectedUtcOffset          = _dateTimeResolver.GetTimeSpanByZoneId(_blogConfig.GeneralSettings.TimeZoneId),
                TimeZoneList               = tzList,
                SelectedThemeFileName      = _blogConfig.GeneralSettings.ThemeFileName,
                ThemeList                  = tmList
            };

            return(View(vm));
        }
Пример #2
0
        public async Task <IActionResult> General(GeneralSettingsViewModel model, [FromServices] IDateTimeResolver dateTimeResolver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _blogConfig.GeneralSettings.MetaKeyword                = model.MetaKeyword;
            _blogConfig.GeneralSettings.MetaDescription            = model.MetaDescription;
            _blogConfig.GeneralSettings.CanonicalPrefix            = model.CanonicalPrefix;
            _blogConfig.GeneralSettings.SiteTitle                  = model.SiteTitle;
            _blogConfig.GeneralSettings.Copyright                  = model.Copyright;
            _blogConfig.GeneralSettings.LogoText                   = model.LogoText;
            _blogConfig.GeneralSettings.SideBarCustomizedHtmlPitch = model.SideBarCustomizedHtmlPitch;
            _blogConfig.GeneralSettings.SideBarOption              = Enum.Parse <SideBarOption>(model.SideBarOption);
            _blogConfig.GeneralSettings.FooterCustomizedHtmlPitch  = model.FooterCustomizedHtmlPitch;
            _blogConfig.GeneralSettings.TimeZoneUtcOffset          = dateTimeResolver.GetTimeSpanByZoneId(model.SelectedTimeZoneId).ToString();
            _blogConfig.GeneralSettings.TimeZoneId                 = model.SelectedTimeZoneId;
            _blogConfig.GeneralSettings.ThemeFileName              = model.SelectedThemeFileName;
            _blogConfig.GeneralSettings.OwnerName                  = model.OwnerName;
            _blogConfig.GeneralSettings.Description                = model.OwnerDescription;
            _blogConfig.GeneralSettings.ShortDescription           = model.OwnerShortDescription;
            _blogConfig.GeneralSettings.AutoDarkLightTheme         = model.AutoDarkLightTheme;

            await _blogConfig.SaveAsync(_blogConfig.GeneralSettings);

            AppDomain.CurrentDomain.SetData("CurrentThemeColor", null);

            await _blogAudit.AddAuditEntry(EventType.Settings, AuditEventId.SettingsSavedGeneral, "General Settings updated.");

            return(Ok());
        }
Пример #3
0
        public IActionResult General([FromServices] IDateTimeResolver dateTimeResolver)
        {
            var vm = new GeneralSettingsViewModel
            {
                LogoText                   = _blogConfig.GeneralSettings.LogoText,
                MetaKeyword                = _blogConfig.GeneralSettings.MetaKeyword,
                MetaDescription            = _blogConfig.GeneralSettings.MetaDescription,
                CanonicalPrefix            = _blogConfig.GeneralSettings.CanonicalPrefix,
                SiteTitle                  = _blogConfig.GeneralSettings.SiteTitle,
                Copyright                  = _blogConfig.GeneralSettings.Copyright,
                SideBarCustomizedHtmlPitch = _blogConfig.GeneralSettings.SideBarCustomizedHtmlPitch,
                FooterCustomizedHtmlPitch  = _blogConfig.GeneralSettings.FooterCustomizedHtmlPitch,
                OwnerName                  = _blogConfig.GeneralSettings.OwnerName,
                OwnerDescription           = _blogConfig.GeneralSettings.Description,
                OwnerShortDescription      = _blogConfig.GeneralSettings.ShortDescription,
                SelectedTimeZoneId         = _blogConfig.GeneralSettings.TimeZoneId,
                SelectedUtcOffset          = dateTimeResolver.GetTimeSpanByZoneId(_blogConfig.GeneralSettings.TimeZoneId),
                SelectedThemeFileName      = _blogConfig.GeneralSettings.ThemeFileName,
                AutoDarkLightTheme         = _blogConfig.GeneralSettings.AutoDarkLightTheme
            };

            return(View(vm));
        }