public StatcounterController(ILocalizationService localizationService,
                              INotificationService notificationService,
                              IPermissionService permissionService,
                              ISettingService settingService,
                              StatcounterSettings settings)
 {
     _localizationService = localizationService;
     _notificationService = notificationService;
     _permissionService   = permissionService;
     _settingService      = settingService;
     _settings            = settings;
 }
        public IActionResult Configure()
        {
            //whether user has the authority to manage configuration
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))
            {
                return(AccessDeniedView());
            }

            //prepare common model
            var model = new StatcounterSettings
            {
                StatcounterCode = _settings.StatcounterCode
            };

            return(View("~/Plugins/FreemiumMedia.Nop.Plugin.Widgets.Statcounter/Views/Configure.cshtml", model));
        }
        public IActionResult Configure(StatcounterSettings model)
        {
            //whether user has the authority to manage configuration
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedView());
            }

            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //save settings
            _settings.StatcounterCode = model.StatcounterCode;

            _settingService.SaveSetting(_settings);

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

            return(Configure());
        }