public ActionResult Edit(SettingModel model)
        {
            // Check the user's permissions
            if (!_permissionService.Authorize(PermissionProvider.ManageSettings))
                return AccessDeniedView();

            // Get the setting
            var setting = _settingService.GetSettingById(model.Id);
            if (setting == null || setting.Deleted)
                return RedirectToAction("Index");

            // Ensure the form is valid
            if (ModelState.IsValid)
            {
                try
                {
                    setting.LastModifiedBy = _workContext.CurrentUser.Id;
                    setting.Value = model.Value;
                    _settingService.UpdateSetting(setting, true);

                    SuccessNotification("The setting details have been updated successfully.");
                    return RedirectToAction("Edit", setting.Id);
                }
                catch
                {
                    ErrorNotification("An error occurred saving the setting details, please try again.");
                }
            }
            else
            {
                ErrorNotification("We were unable to make the change, please review the form and correct the errors.");
            }

            // Build breacrumbs
            PrepareBreadcrumbs();
            AddBreadcrumb("Edit Setting", null);

            return View(model);
        }
        public static SettingModel ToModel(this Setting entity)
        {
            if (entity == null)
                return null;

            var model = new SettingModel
            {
                Name = entity.Name,
                Value = entity.Value
            };

            return model;
        }