Наследование: Nop.Web.Framework.Mvc.BaseNopModel
Пример #1
0
        public ActionResult ShoppingCart(ShoppingCartSettingsModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            _shoppingCartSettings = model.ToEntity(_shoppingCartSettings);
            _settingService.SaveSetting(_shoppingCartSettings);

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

            SuccessNotification(_localizationService.GetResource("Admin.Configuration.Updated"));
            return RedirectToAction("ShoppingCart");
        }
Пример #2
0
        public ActionResult ShoppingCart(ShoppingCartSettingsModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            //load settings for a chosen store scope
            var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var shoppingCartSettings = _settingService.LoadSetting<ShoppingCartSettings>(storeScope);
            shoppingCartSettings = model.ToEntity(shoppingCartSettings);

            /* 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 */
            if (model.DisplayCartAfterAddingProduct_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.DisplayCartAfterAddingProduct, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.DisplayCartAfterAddingProduct, storeScope);

            if (model.DisplayWishlistAfterAddingProduct_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.DisplayWishlistAfterAddingProduct, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.DisplayWishlistAfterAddingProduct, storeScope);

            if (model.MaximumShoppingCartItems_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.MaximumShoppingCartItems, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.MaximumShoppingCartItems, storeScope);

            if (model.MaximumWishlistItems_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.MaximumWishlistItems, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.MaximumWishlistItems, storeScope);

            if (model.AllowOutOfStockItemsToBeAddedToWishlist_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.AllowOutOfStockItemsToBeAddedToWishlist, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.AllowOutOfStockItemsToBeAddedToWishlist, storeScope);

            if (model.MoveItemsFromWishlistToCart_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.MoveItemsFromWishlistToCart, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.MoveItemsFromWishlistToCart, storeScope);

            if (model.ShowProductImagesOnShoppingCart_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.ShowProductImagesOnShoppingCart, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.ShowProductImagesOnShoppingCart, storeScope);

            if (model.ShowProductImagesOnWishList_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.ShowProductImagesOnWishList, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.ShowProductImagesOnWishList, storeScope);

            if (model.ShowDiscountBox_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.ShowDiscountBox, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.ShowDiscountBox, storeScope);

            if (model.ShowGiftCardBox_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.ShowGiftCardBox, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.ShowGiftCardBox, storeScope);

            if (model.CrossSellsNumber_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.CrossSellsNumber, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.CrossSellsNumber, storeScope);

            if (model.EmailWishlistEnabled_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.EmailWishlistEnabled, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.EmailWishlistEnabled, storeScope);

            if (model.AllowAnonymousUsersToEmailWishlist_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.AllowAnonymousUsersToEmailWishlist, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.AllowAnonymousUsersToEmailWishlist, storeScope);

            if (model.MiniShoppingCartEnabled_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.MiniShoppingCartEnabled, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.MiniShoppingCartEnabled, storeScope);

            if (model.ShowProductImagesInMiniShoppingCart_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.ShowProductImagesInMiniShoppingCart, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.ShowProductImagesInMiniShoppingCart, storeScope);

            if (model.MiniShoppingCartProductNumber_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.MiniShoppingCartProductNumber, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.MiniShoppingCartProductNumber, storeScope);

            if (model.AllowCartItemEditing_OverrideForStore || storeScope == 0)
                _settingService.SaveSetting(shoppingCartSettings, x => x.AllowCartItemEditing, storeScope, false);
            else if (storeScope > 0)
                _settingService.DeleteSetting(shoppingCartSettings, x => x.AllowCartItemEditing, storeScope);

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

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

            SuccessNotification(_localizationService.GetResource("Admin.Configuration.Updated"));
            return RedirectToAction("ShoppingCart");
        }