public override async Task <IDisplayResult> UpdateAsync(CommerceSettings section, BuildEditorContext context)
        {
            var user = _httpContextAccessor.HttpContext?.User;

            if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageCommerceSettings))
            {
                return(null);
            }

            if (context.GroupId == GroupId)
            {
                var model = new CommerceSettingsViewModel();

                if (await context.Updater.TryUpdateModelAsync(model, Prefix))
                {
                    section.DefaultCurrency        = model.DefaultCurrency;
                    section.CurrentDisplayCurrency = model.CurrentDisplayCurrency;
                }

                // Reload the tenant to apply the settings
                await _orchardHost.ReloadShellContextAsync(_currentShellSettings);
            }

            return(await EditAsync(section, context));
        }
예제 #2
0
        public async Task <IActionResult> SaveCommerceSettings(CommerceSettingsViewModel model)
        {
            await _productService.AddOrUpdateSettingAsync(CommerceResources.SettingsParameters.CURRENCY, model.CurrencyCode);

            await _productService.AddOrUpdateSettingAsync(CommerceResources.SettingsParameters.DAYS_NOTIFY_SUBSCRIPTION_EXPIRATION,
                                                          model.DaysToNotifyExpiringSubscriptions, CommerceSettingType.Number);

            await _productService.AddOrUpdateSettingAsync(CommerceResources.SettingsParameters.FREE_TRIAL_PERIOD_DAYS,
                                                          model.DaysToFreeTrialPeriod, CommerceSettingType.Number);

            return(RedirectToAction(nameof(Index)));
        }
예제 #3
0
        public async Task <IActionResult> Index()
        {
            var daysNotifySubscription = (await _productService.GetSettingAsync <string>(CommerceResources.SettingsParameters.DAYS_NOTIFY_SUBSCRIPTION_EXPIRATION)).Result ?? "0";
            var dayFreeTrialPeriod     = (await _productService.GetSettingAsync <string>(CommerceResources.SettingsParameters.FREE_TRIAL_PERIOD_DAYS)).Result ?? "15";

            var model = new CommerceSettingsViewModel
            {
                Currencies   = (await _productService.GetAllCurrenciesAsync()).Result,
                CurrencyCode = (await _productService.GetSettingAsync <string>(CommerceResources.SettingsParameters.CURRENCY)).Result,
                DaysToNotifyExpiringSubscriptions = Convert.ToInt32(daysNotifySubscription),
                DaysToFreeTrialPeriod             = Convert.ToInt32(dayFreeTrialPeriod),
            };

            return(View(model));
        }