public ActionResult SettingUpdate(SettingModel model, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

            if (model.Name != null)
                model.Name = model.Name.Trim();
            if (model.Value != null)
                model.Value = model.Value.Trim();

            if (!ModelState.IsValid)
            {
                //display the first model error
                var modelStateErrors = this.ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage);
                return Content(modelStateErrors.FirstOrDefault());
            }

            var setting = _settingService.GetSettingById(model.Id);
			if (setting == null)
				return Content(_localizationService.GetResource("Admin.Configuration.Settings.NoneWithThatId"));

			var storeId = model.Store.ToInt(); //use Store property (not StoreId) because appropriate property is stored in it

			if (!setting.Name.Equals(model.Name, StringComparison.InvariantCultureIgnoreCase) ||
				setting.StoreId != storeId)
			{
				//setting name or store has been changed
				_settingService.DeleteSetting(setting);
			}

			_settingService.SetSetting(model.Name, model.Value, storeId);

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

            return AllSettings(command);
        }
		public ActionResult AllSettings(GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
                return AccessDeniedView();

			var stores = _storeService.GetAllStores();
			string allStoresString = _localizationService.GetResource("Admin.Common.StoresAll");
            
            var settings = _settingService
                .GetAllSettings()
				.Select(x =>
				{
					var settingModel = new SettingModel()
					{
						Id = x.Id,
						Name = x.Name,
						Value = x.Value,
						StoreId = x.StoreId
					};

					if (x.StoreId == 0)
					{
						settingModel.Store = allStoresString;
					}
					else
					{
						var store = stores.FirstOrDefault(s => s.Id == x.StoreId);
						settingModel.Store = store != null ? store.Name : "Unknown";
					}

					return settingModel;
				})
                .ForCommand(command)
                .ToList();
            
            var model = new GridModel<SettingModel>
            {
                Data = settings.PagedForCommand(command),
                Total = settings.Count
            };

            return new JsonResult
            {
                Data = model
            };
        }