Пример #1
0
        public async Task <IActionResult> General([FromForm] MagicWrapper <GeneralSettingsViewModel> wrapperModel, [FromServices] ITimeZoneResolver timeZoneResolver)
        {
            var model = wrapperModel.ViewModel;

            var settings = _blogConfig.GeneralSettings;

            settings.MetaKeyword                = model.MetaKeyword;
            settings.MetaDescription            = model.MetaDescription;
            settings.CanonicalPrefix            = model.CanonicalPrefix;
            settings.SiteTitle                  = model.SiteTitle;
            settings.Copyright                  = model.Copyright;
            settings.LogoText                   = model.LogoText;
            settings.SideBarCustomizedHtmlPitch = model.SideBarCustomizedHtmlPitch;
            settings.SideBarOption              = Enum.Parse <SideBarOption>(model.SideBarOption);
            settings.FooterCustomizedHtmlPitch  = model.FooterCustomizedHtmlPitch;
            settings.TimeZoneUtcOffset          = timeZoneResolver.GetTimeSpanByZoneId(model.SelectedTimeZoneId).ToString();
            settings.TimeZoneId                 = model.SelectedTimeZoneId;
            settings.ThemeId            = model.SelectedThemeId;
            settings.OwnerName          = model.OwnerName;
            settings.OwnerEmail         = model.OwnerEmail;
            settings.Description        = model.OwnerDescription;
            settings.ShortDescription   = model.OwnerShortDescription;
            settings.AutoDarkLightTheme = model.AutoDarkLightTheme;

            await _blogConfig.SaveAsync(_blogConfig.GeneralSettings);

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

            await _blogAudit.AddEntry(BlogEventType.Settings, BlogEventId.SettingsSavedGeneral, "General Settings updated.");

            return(NoContent());
        }
Пример #2
0
        public async Task OnGetAsync()
        {
            ViewModel = new()
            {
                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,
                SideBarOption              = _blogConfig.GeneralSettings.SideBarOption.ToString(),
                FooterCustomizedHtmlPitch  = _blogConfig.GeneralSettings.FooterCustomizedHtmlPitch,
                OwnerName                  = _blogConfig.GeneralSettings.OwnerName,
                OwnerEmail                 = _blogConfig.GeneralSettings.OwnerEmail,
                OwnerDescription           = _blogConfig.GeneralSettings.Description,
                OwnerShortDescription      = _blogConfig.GeneralSettings.ShortDescription,
                SelectedTimeZoneId         = _blogConfig.GeneralSettings.TimeZoneId,
                SelectedUtcOffset          = _timeZoneResolver.GetTimeSpanByZoneId(_blogConfig.GeneralSettings.TimeZoneId),
                SelectedThemeId            = _blogConfig.GeneralSettings.ThemeId,
                AutoDarkLightTheme         = _blogConfig.GeneralSettings.AutoDarkLightTheme
            };

            Themes = await _themeService.GetAllSegment();
        }
    }
Пример #3
0
    public async Task OnGetAsync()
    {
        ViewModel = _blogConfig.GeneralSettings;
        ViewModel.SelectedUtcOffset = _timeZoneResolver.GetTimeSpanByZoneId(_blogConfig.GeneralSettings.TimeZoneId);

        Themes = await _mediator.Send(new GetAllThemeSegmentQuery());
    }
Пример #4
0
    public async Task <IActionResult> General([FromForm] MagicWrapper <GeneralSettings> wrapperModel, [FromServices] ITimeZoneResolver timeZoneResolver)
    {
        var model = wrapperModel.ViewModel;

        _blogConfig.GeneralSettings = model;
        _blogConfig.GeneralSettings.TimeZoneUtcOffset = timeZoneResolver.GetTimeSpanByZoneId(model.TimeZoneId).ToString();

        await _blogConfig.SaveAsync(_blogConfig.GeneralSettings);

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

        return(NoContent());
    }