Example #1
0
        public IActionResult Configure(ExtendedRewardPointsProgramModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            var storeScope = _storeContext.ActiveStoreScopeConfiguration;

            //save settings
            SaveSettings(_settingService.LoadSetting <RewardPointsForBlogCommentsSettings>(storeScope), model.ForBlogComments, storeScope);
            SaveSettings(_settingService.LoadSetting <RewardPointsForFirstPurchaseSettings>(storeScope), model.ForFirstPurchase, storeScope);
            SaveSettings(_settingService.LoadSetting <RewardPointsForNewsCommentsSettings>(storeScope), model.ForNewsComments, storeScope);
            SaveSettings(_settingService.LoadSetting <RewardPointsForNewsletterSubscriptionsSettings>(storeScope), model.ForNewsletterSubscriptions, storeScope);
            SaveSettings(_settingService.LoadSetting <RewardPointsForProductReviewsSettings>(storeScope), model.ForProductReviews, storeScope);
            SaveSettings(_settingService.LoadSetting <RewardPointsForRegistrationSettings>(storeScope), model.ForRegistration, storeScope);

            var rewardPointsForFastPurchaseSettings = _settingService.LoadSetting <RewardPointsForFastPurchaseSettings>(storeScope);

            SaveSettings(rewardPointsForFastPurchaseSettings, model.ForFastPurchase, storeScope);
            rewardPointsForFastPurchaseSettings.Minutes = model.ForFastPurchase.Minutes;
            _settingService.SaveSettingOverridablePerStore(rewardPointsForFastPurchaseSettings, x => x.Minutes, model.ForFastPurchase.Minutes_OverrideForStore, storeScope, false);

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

            SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));

            return(Configure());
        }
Example #2
0
        public IActionResult Configure()
        {
            var model = new ExtendedRewardPointsProgramModel
            {
                //check for multistore
                IsMultistore = _storeService.GetAllStores().Count > 1
            };

            var storeScope = _storeContext.ActiveStoreScopeConfiguration;

            //prepare models
            model.ForBlogComments = PrepareModel(_settingService.LoadSetting <RewardPointsForBlogCommentsSettings>(storeScope), storeScope,
                                                 _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForBlogComments"),
                                                 _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForBlogComments.Hint"));

            model.ForFirstPurchase = PrepareModel(_settingService.LoadSetting <RewardPointsForFirstPurchaseSettings>(storeScope), storeScope,
                                                  _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForFirstPurchase"),
                                                  _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForFirstPurchase.Hint"));

            model.ForNewsComments = PrepareModel(_settingService.LoadSetting <RewardPointsForNewsCommentsSettings>(storeScope), storeScope,
                                                 _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForNewsComments"),
                                                 _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForNewsComments.Hint"));

            model.ForNewsletterSubscriptions = PrepareModel(_settingService.LoadSetting <RewardPointsForNewsletterSubscriptionsSettings>(storeScope), storeScope,
                                                            _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForNewsletterSubscriptions"),
                                                            _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForNewsletterSubscriptions.Hint"));

            model.ForProductReviews = PrepareModel(_settingService.LoadSetting <RewardPointsForProductReviewsSettings>(storeScope), storeScope,
                                                   _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForProductReviews"),
                                                   _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForProductReviews.Hint"));

            model.ForRegistration = PrepareModel(_settingService.LoadSetting <RewardPointsForRegistrationSettings>(storeScope), storeScope,
                                                 _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForRegistration"),
                                                 _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForRegistration.Hint"));

            var settings = _settingService.LoadSetting <RewardPointsForFastPurchaseSettings>(storeScope);

            model.ForFastPurchase = PrepareModel(settings, storeScope,
                                                 _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForFastPurchase"),
                                                 _localizationService.GetResource("Plugins.Misc.ExtendedRewardPointsProgram.ForFastPurchase.Hint"));

            model.ForFastPurchase.Minutes = settings.Minutes;
            model.ForFastPurchase.Minutes_OverrideForStore = storeScope > 0 && _settingService.SettingExists(settings, x => x.Minutes, storeScope);

            return(View("~/Plugins/Misc.ExtendedRewardPointsProgram/Views/Configure.cshtml", model));
        }