Esempio n. 1
0
        public ActionResult Configure(SmsClickatellModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //load settings for a chosen store scope
            var storeScope         = GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var clickatellSettings = _settingService.LoadSetting <ClickatellSettings>(storeScope);

            //save settings
            clickatellSettings.Enabled     = model.Enabled;
            clickatellSettings.ApiId       = model.ApiId;
            clickatellSettings.Username    = model.Username;
            clickatellSettings.Password    = model.Password;
            clickatellSettings.PhoneNumber = model.PhoneNumber;

            /* 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 */
            _settingService.SaveSetting(clickatellSettings, x => x.ApiId, storeScope, false);
            _settingService.SaveSetting(clickatellSettings, x => x.Username, storeScope, false);
            _settingService.SaveSetting(clickatellSettings, x => x.Password, storeScope, false);
            _settingService.SaveSettingOverridablePerStore(clickatellSettings, x => x.Enabled, model.Enabled_OverrideForStore, storeScope, false);
            _settingService.SaveSettingOverridablePerStore(clickatellSettings, x => x.PhoneNumber, model.PhoneNumber_OverrideForStore, storeScope, false);

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

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

            return(Configure());
        }
Esempio n. 2
0
        public IActionResult Configure()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(AccessDeniedView());
            }

            //load settings for a chosen store scope
            var storeScope         = _storeContext.ActiveStoreScopeConfiguration;
            var clickatellSettings = _settingService.LoadSetting <ClickatellSettings>(storeScope);

            var model = new SmsClickatellModel
            {
                Enabled     = clickatellSettings.Enabled,
                ApiId       = clickatellSettings.ApiId,
                Password    = clickatellSettings.Password,
                Username    = clickatellSettings.Username,
                PhoneNumber = clickatellSettings.PhoneNumber,
                ActiveStoreScopeConfiguration = storeScope
            };

            if (storeScope > 0)
            {
                model.Enabled_OverrideForStore     = _settingService.SettingExists(clickatellSettings, x => x.Enabled, storeScope);
                model.PhoneNumber_OverrideForStore = _settingService.SettingExists(clickatellSettings, x => x.PhoneNumber, storeScope);
            }

            return(View("~/Plugins/SMS.Clickatell/Views/Configure.cshtml", model));
        }
        public ActionResult TestSms(SmsClickatellModel model)
        {
            try
            {
                if (model.TestMessage.IsEmpty())
                {
                    model.TestSucceeded = false;
                    model.TestSmsResult = T("Plugins.Sms.Clickatell.EnterMessage");
                }
                else
                {
                    var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName(ClickatellSmsProvider.SystemName);
                    var plugin           = pluginDescriptor.Instance() as ClickatellSmsProvider;

                    plugin.SendSms(model.TestMessage);

                    model.TestSucceeded = true;
                    model.TestSmsResult = T("Plugins.Sms.Clickatell.TestSuccess");
                }
            }
            catch (Exception exception)
            {
                model.TestSucceeded       = false;
                model.TestSmsResult       = T("Plugins.Sms.Clickatell.TestFailed");
                model.TestSmsDetailResult = exception.Message;
            }

            return(View("Configure", model));
        }
Esempio n. 4
0
        public ActionResult TestSms(SmsClickatellModel model)
        {
            try
            {
                if (String.IsNullOrEmpty(model.TestMessage))
                {
                    model.TestSmsResult = "Enter test message";
                }
                else
                {
                    var smsProvider = _smsService.LoadSmsProviderBySystemName("Mobile.SMS.Clickatell");

                    if (!smsProvider.SendSms(model.TestMessage))
                    {
                        model.TestSmsResult = _localizationService.GetResource("Plugins.Sms.Clickatell.TestFailed");
                    }
                    else
                    {
                        model.TestSmsResult = _localizationService.GetResource("Plugins.Sms.Clickatell.TestSuccess");
                    }
                }
            }
            catch (Exception exc)
            {
                model.TestSmsResult = exc.ToString();
            }

            return(View("Nop.Plugin.SMS.Clickatell.Views.SmsClickatell.Configure", model));
        }
        public ActionResult Configure(ClickatellSettings settings)
        {
            var model = new SmsClickatellModel();

            MiniMapper.Map(settings, model);

            return(View(model));
        }
Esempio n. 6
0
        public ActionResult Configure()
        {
            var model = new SmsClickatellModel();

            model.PhoneNumber = _clickatellSettings.PhoneNumber;
            model.ApiId       = _clickatellSettings.ApiId;
            model.Username    = _clickatellSettings.Username;
            model.Password    = _clickatellSettings.Password;
            return(View("Nop.Plugin.SMS.Clickatell.Views.SmsClickatell.Configure", model));
        }
Esempio n. 7
0
        public ActionResult Configure()
        {
            var model = new SmsClickatellModel();

            model.Enabled     = _clickatellSettings.Enabled;
            model.PhoneNumber = _clickatellSettings.PhoneNumber;
            model.ApiId       = _clickatellSettings.ApiId;
            model.Username    = _clickatellSettings.Username;
            model.Password    = _clickatellSettings.Password;
            return(View(model));
        }
        public ActionResult Configure(ClickatellSettings settings, SmsClickatellModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure(settings));
            }

            MiniMapper.Map(model, settings);
            settings.ApiId = model.ApiId.TrimSafe();

            NotifySuccess(T("Admin.Common.DataSuccessfullySaved"));

            return(RedirectToConfiguration(ClickatellSmsProvider.SystemName));
        }
Esempio n. 9
0
        public ActionResult ConfigurePOST(SmsClickatellModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //save settings
            _clickatellSettings.PhoneNumber = model.PhoneNumber;
            _clickatellSettings.ApiId       = model.ApiId;
            _clickatellSettings.Username    = model.Username;
            _clickatellSettings.Password    = model.Password;
            _settingService.SaveSetting(_clickatellSettings);

            return(View("Nop.Plugin.SMS.Clickatell.Views.SmsClickatell.Configure", model));
        }
        public ActionResult Configure()
        {
            var storeScope = this.GetActiveStoreScopeConfiguration(_services.StoreService, _services.WorkContext);
            var settings   = _services.Settings.LoadSetting <ClickatellSettings>(storeScope);

            var model = new SmsClickatellModel
            {
                Enabled     = settings.Enabled,
                PhoneNumber = settings.PhoneNumber,
                ApiId       = settings.ApiId
            };

            var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);

            storeDependingSettingHelper.GetOverrideKeys(settings, model, storeScope, _services.Settings);

            return(View(model));
        }
        public ActionResult Configure(SmsClickatellModel model, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                var storeDependingSettingHelper = new StoreDependingSettingHelper(ViewData);
                int storeScope = this.GetActiveStoreScopeConfiguration(_services.StoreService, _services.WorkContext);
                var settings   = _services.Settings.LoadSetting <ClickatellSettings>(storeScope);

                settings.Enabled     = model.Enabled;
                settings.PhoneNumber = model.PhoneNumber;
                settings.ApiId       = model.ApiId;

                storeDependingSettingHelper.UpdateSettings(settings, form, storeScope, _services.Settings);

                NotifySuccess(T("Admin.Common.DataSuccessfullySaved"));
            }

            return(Configure());
        }
        public ActionResult TestSms(SmsClickatellModel model)
        {
            try
            {
                if (String.IsNullOrEmpty(model.TestMessage))
                {
                    model.TestSmsResult = "Enter test message";
                }
                else
                {
                    var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("Mobile.SMS.Clickatell");
                    if (pluginDescriptor == null)
                    {
                        throw new Exception("Cannot load the plugin");
                    }
                    var plugin = pluginDescriptor.Instance() as ClickatellSmsProvider;
                    if (plugin == null)
                    {
                        throw new Exception("Cannot load the plugin");
                    }

                    if (!plugin.SendSms(model.TestMessage))
                    {
                        model.TestSmsResult = _localizationService.GetResource("Plugins.Sms.Clickatell.TestFailed");
                    }
                    else
                    {
                        model.TestSmsResult = _localizationService.GetResource("Plugins.Sms.Clickatell.TestSuccess");
                    }
                }
            }
            catch (Exception exc)
            {
                model.TestSmsResult = exc.ToString();
            }

            return(View("SmartStore.Plugin.SMS.Clickatell.Views.SmsClickatell.Configure", model));
        }
Esempio n. 13
0
        public IActionResult TestSms(SmsClickatellModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName("Mobile.SMS.Clickatell");

            if (pluginDescriptor == null)
            {
                throw new Exception("Cannot load the plugin");
            }

            var plugin = pluginDescriptor.Instance() as ClickatellSmsProvider;

            if (plugin == null)
            {
                throw new Exception("Cannot load the plugin");
            }

            //load settings for a chosen store scope
            var storeScope         = _storeContext.ActiveStoreScopeConfiguration;
            var clickatellSettings = _settingService.LoadSetting <ClickatellSettings>(storeScope);

            //test SMS send
            if (plugin.SendSms(model.TestMessage, 0, clickatellSettings))
            {
                SuccessNotification(_localizationService.GetResource("Plugins.Sms.Clickatell.TestSuccess"));
            }
            else
            {
                ErrorNotification(_localizationService.GetResource("Plugins.Sms.Clickatell.TestFailed"));
            }

            return(Configure());
        }
Esempio n. 14
0
        public ActionResult Configure()
        {
            //load settings for a chosen store scope
            var storeScope         = GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var clickatellSettings = _settingService.LoadSetting <ClickatellSettings>(storeScope);

            var model = new SmsClickatellModel
            {
                Enabled     = clickatellSettings.Enabled,
                ApiId       = clickatellSettings.ApiId,
                Password    = clickatellSettings.Password,
                Username    = clickatellSettings.Username,
                PhoneNumber = clickatellSettings.PhoneNumber,
                ActiveStoreScopeConfiguration = storeScope
            };

            if (storeScope > 0)
            {
                model.Enabled_OverrideForStore     = _settingService.SettingExists(clickatellSettings, x => x.Enabled, storeScope);
                model.PhoneNumber_OverrideForStore = _settingService.SettingExists(clickatellSettings, x => x.PhoneNumber, storeScope);
            }

            return(View("~/Plugins/SMS.Clickatell/Views/SmsClickatell/Configure.cshtml", model));
        }