Ejemplo n.º 1
0
        public ActionResult ListPost(ThemeListModel model, FormCollection form)
        {
            var themeSettings = Services.Settings.LoadSetting <ThemeSettings>(model.StoreId);

            var themeSwitched = themeSettings.DefaultTheme.IsCaseInsensitiveEqual(model.DefaultTheme);

            if (themeSwitched)
            {
                Services.EventPublisher.Publish(new ThemeSwitchedEvent
                {
                    OldTheme = themeSettings.DefaultTheme,
                    NewTheme = model.DefaultTheme
                });
            }

            var bundlingOnNow    = themeSettings.BundleOptimizationEnabled == 2 || (themeSettings.BundleOptimizationEnabled == 0 && !HttpContext.IsDebuggingEnabled);
            var bundlingOnFuture = model.BundleOptimizationEnabled == 2 || (model.BundleOptimizationEnabled == 0 && !HttpContext.IsDebuggingEnabled);

            if (bundlingOnNow != bundlingOnFuture)
            {
                // Clear asset cache, otherwise we get problems with postprocessing, minification etc.
                _assetCache.Clear();
            }

            themeSettings = model.ToEntity(themeSettings);
            Services.Settings.SaveSetting(themeSettings, model.StoreId);

            Services.EventPublisher.Publish(new ModelBoundEvent(model, themeSettings, form));

            NotifySuccess(T("Admin.Configuration.Updated"));

            return(RedirectToAction("List", new { storeId = model.StoreId }));
        }
Ejemplo n.º 2
0
        public ActionResult ListPost(ThemeListModel model, FormCollection form)
        {
            if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageThemes))
            {
                return(AccessDeniedView());
            }

            var themeSettings = _settingService.LoadSetting <ThemeSettings>(model.StoreId);

            bool themeSwitched = themeSettings.DefaultTheme.IsCaseInsensitiveEqual(model.DefaultTheme);

            if (themeSwitched)
            {
                _services.EventPublisher.Publish <ThemeSwitchedEvent>(new ThemeSwitchedEvent {
                    OldTheme = themeSettings.DefaultTheme,
                    NewTheme = model.DefaultTheme
                });
            }

            var bundlingOnNow    = themeSettings.BundleOptimizationEnabled == 2 || (themeSettings.BundleOptimizationEnabled == 0 && !HttpContext.IsDebuggingEnabled);
            var bundlingOnFuture = model.BundleOptimizationEnabled == 2 || (model.BundleOptimizationEnabled == 0 && !HttpContext.IsDebuggingEnabled);

            if (bundlingOnNow != bundlingOnFuture)
            {
                // Clear asset cache, otherwise we get problems with postprocessing, minification etc.
                _assetCache.Clear();
            }

            themeSettings = model.ToEntity(themeSettings);
            _settingService.SaveSetting(themeSettings, model.StoreId);

            _services.CustomerActivity.InsertActivity("EditSettings", T("ActivityLog.EditSettings"));

            _services.EventPublisher.Publish(new ModelBoundEvent(model, themeSettings, form));

            NotifySuccess(T("Admin.Configuration.Updated"));

            return(RedirectToAction("List", new { storeId = model.StoreId }));
        }