Пример #1
0
        public virtual IActionResult Media(MediaSettingsModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            //load settings for a chosen site scope
            var mediaSettings = _settingService.LoadSetting <MediaSettings>();

            mediaSettings = model.ToSettings(mediaSettings);

            //we do not clear cache after each setting update.
            //this behavior can increase performance because cached settings will not be cleared
            //and loaded from database after each update
            _settingService.SaveSetting(mediaSettings, x => x.AvatarPictureSize, true);
            _settingService.SaveSetting(mediaSettings, x => x.MaximumImageSize, true);
            _settingService.SaveSetting(mediaSettings, x => x.MultipleThumbDirectories, true);
            _settingService.SaveSetting(mediaSettings, x => x.DefaultImageQuality, true);

            //now clear settings cache
            _settingService.ClearCache();

            //activity log
            _userActivityService.InsertActivity("EditSettings", _localizationService.GetResource("ActivityLog.EditSettings"));

            SuccessNotification(_localizationService.GetResource("Admin.Configuration.Updated"));

            return(RedirectToAction("Media"));
        }
Пример #2
0
        public async Task <IActionResult> Media(MediaSettingsModel model)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            var tenantScope   = _tenantContext.ActiveTenantScopeConfiguration;
            var mediaSettings = _settingService.LoadSetting <MediaSettings>(tenantScope);

            mediaSettings = model.ToSettings(mediaSettings);

            await _settingService.SaveSettingOverridablePerTenant(mediaSettings, x => x.AvatarPictureSize, model.AvatarPictureSize_OverrideForTenant, tenantScope, false);

            await _settingService.SaveSettingOverridablePerTenant(mediaSettings, x => x.MaximumImageSize, model.MaximumImageSize_OverrideForTenant, tenantScope, false);

            await _settingService.SaveSettingOverridablePerTenant(mediaSettings, x => x.DefaultImageQuality, model.DefaultImageQuality_OverrideForTenant, tenantScope, false);

            _settingService.ClearCache();

            await _userActivityService.InsertActivityAsync("EditSettings", "Edited settings");

            _notificationService.SuccessNotification("The settings have been updated successfully.");

            return(RedirectToAction("Media"));
        }