Esempio n. 1
0
        public ActionResult Configure()
        {
            var storeScope = GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var customersCanvasSettings = _settingService.LoadSetting <CcSettings>(storeScope);
            var model = new CcSettingsViewModel
            {
                ServerHostUrl                 = customersCanvasSettings.ServerHostUrl,
                CustomersCanvasApiKey         = customersCanvasSettings.CustomersCanvasApiKey,
                ActiveStoreScopeConfiguration = storeScope,
                DesignFileName                = customersCanvasSettings.DesignFileName,
                IsOrderExportButton           = customersCanvasSettings.IsOrderExportButton,
                OrderExportPath               = customersCanvasSettings.OrderExportPath
            };

            if (storeScope > 0)
            {
                model.ServerHostUrl_OverrideForStore = _settingService.SettingExists(customersCanvasSettings,
                                                                                     x => x.ServerHostUrl, storeScope);
            }
            return(View("~/Plugins/Widgets.CustomersCanvas/Views/Configure.cshtml", model));
        }
Esempio n. 2
0
        public ActionResult Configure(CcSettingsViewModel model)
        {
            var storeScope = GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var customersCanvasSettings = _settingService.LoadSetting <CcSettings>(storeScope);

            customersCanvasSettings.ServerHostUrl = model.ServerHostUrl;
            if (model.ServerHostUrl_OverrideForStore || storeScope == 0)
            {
                _settingService.SaveSetting(customersCanvasSettings, x => x.ServerHostUrl, storeScope, false);
            }
            else if (storeScope > 0)
            {
                _settingService.DeleteSetting(customersCanvasSettings, x => x.ServerHostUrl, storeScope);
            }

            customersCanvasSettings.DesignFileName = model.DesignFileName;
            _settingService.SaveSetting(customersCanvasSettings, x => x.DesignFileName, storeScope, false);

            customersCanvasSettings.IsOrderExportButton = model.IsOrderExportButton;
            _settingService.SaveSetting(customersCanvasSettings, x => x.IsOrderExportButton, storeScope, false);

            customersCanvasSettings.CustomersCanvasApiKey = model.CustomersCanvasApiKey;
            _settingService.SaveSetting(customersCanvasSettings, x => x.CustomersCanvasApiKey, storeScope, false);

            if (!model.IsOrderExportButton)
            {
                model.OrderExportPath = "";
            }
            customersCanvasSettings.OrderExportPath = model.OrderExportPath;
            _settingService.SaveSetting(customersCanvasSettings, x => x.OrderExportPath, storeScope, false);

            _settingService.ClearCache();

            SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));
            return(Configure());
        }