Exemple #1
0
        public ActionResult TestCanada(TaxStrikeIronModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //clear testing results
            model.TestingUsaResult    = "";
            model.TestingCanadaResult = "";

            try
            {
                var     strikeIronTaxProvider = _taxService.LoadTaxProviderBySystemName("Tax.StrikeIron.Basic") as StrikeIronTaxProvider;
                string  province = model.TestingCanadaProvinceCode;
                string  userId   = model.LicenseKey;
                string  error    = "";
                decimal taxRate  = strikeIronTaxProvider.GetTaxRateCanada(province, userId, ref error);

                if (!String.IsNullOrEmpty(error))
                {
                    model.TestingCanadaResult = error;
                }
                else
                {
                    model.TestingCanadaResult = string.Format("Rate for province {0}: {1}", province, taxRate.ToString("p"));
                }
            }
            catch (Exception exc)
            {
                model.TestingCanadaResult = exc.ToString();
            }

            return(View("~/Plugins/Tax.StrikeIron/Views/TaxStrikeIron/Configure.cshtml", model));
        }
        public ActionResult TestUsa(TaxStrikeIronModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //clear testing results
            model.TestingUsaResult    = "";
            model.TestingCanadaResult = "";

            try
            {
                var     strikeIronTaxProvider = _taxService.LoadTaxProviderBySystemName("Tax.StrikeIron.Basic") as StrikeIronTaxProvider;
                string  zip      = model.TestingUsaZip;
                string  userId   = model.UserId;
                string  password = model.Password;
                string  error    = "";
                decimal taxRate  = strikeIronTaxProvider.GetTaxRateUsa(zip, userId, password, ref error);
                if (!String.IsNullOrEmpty(error))
                {
                    model.TestingUsaResult = error;
                }
                else
                {
                    model.TestingUsaResult = string.Format("Rate for zip {0}: {1}", zip, taxRate.ToString("p"));
                }
            }
            catch (Exception exc)
            {
                model.TestingUsaResult = exc.ToString();
            }

            return(View("Nop.Plugin.Tax.StrikeIron.Views.TaxStrikeIron.Configure", model));
        }
        public ActionResult Configure()
        {
            var model = new TaxStrikeIronModel();

            model.UserId   = _strikeIronTaxSettings.UserId;
            model.Password = _strikeIronTaxSettings.Password;
            model.TestingCanadaProvinceCode = "ON";
            model.TestingUsaZip             = "10001";
            model.TestingUsaResult          = "";
            model.TestingCanadaResult       = "";
            return(View("Nop.Plugin.Tax.StrikeIron.Views.TaxStrikeIron.Configure", model));
        }
Exemple #4
0
        public ActionResult Configure()
        {
            var model = new TaxStrikeIronModel
            {
                LicenseKey = _strikeIronTaxSettings.LicenseKey,
                TestingCanadaProvinceCode = "",
                TestingUsaZip             = "",
                TestingUsaResult          = "",
                TestingCanadaResult       = ""
            };

            return(View("~/Plugins/Tax.StrikeIron/Views/TaxStrikeIron/Configure.cshtml", model));
        }
        public ActionResult ConfigurePOST(TaxStrikeIronModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //clear testing results
            model.TestingUsaResult    = "";
            model.TestingCanadaResult = "";

            //save settings
            _strikeIronTaxSettings.UserId   = model.UserId;
            _strikeIronTaxSettings.Password = model.Password;
            _settingService.SaveSetting(_strikeIronTaxSettings);

            return(View("Nop.Plugin.Tax.StrikeIron.Views.TaxStrikeIron.Configure", model));
        }
Exemple #6
0
        public ActionResult Configure(TaxStrikeIronModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //clear testing results
            model.TestingUsaResult    = "";
            model.TestingCanadaResult = "";

            //save settings
            _strikeIronTaxSettings.LicenseKey = model.LicenseKey;
            _settingService.SaveSetting(_strikeIronTaxSettings);

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

            return(View("~/Plugins/Tax.StrikeIron/Views/TaxStrikeIron/Configure.cshtml", model));
        }
Exemple #7
0
        public ActionResult TestCanada(TaxStrikeIronModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Configure());
            }

            //clear testing results
            model.TestingUsaResult    = "";
            model.TestingCanadaResult = "";

            try
            {
                var     strikeIronTaxProvider = new StrikeIronTaxProvider(_strikeIronTaxSettings);
                string  province = model.TestingCanadaProvinceCode;
                string  userId   = model.UserId;
                string  password = model.Password;
                string  error    = "";
                decimal taxRate  = strikeIronTaxProvider.GetTaxRateCanada(province, userId, password, ref error);
                if (!String.IsNullOrEmpty(error))
                {
                    model.TestingCanadaResult = error;
                }
                else
                {
                    model.TestingCanadaResult = string.Format("Rate for province {0}: {1}", province, taxRate.ToString("p"));
                }
            }
            catch (Exception exc)
            {
                model.TestingCanadaResult = exc.ToString();
            }


            return(View("Nop.Plugin.Tax.StrikeIron.Views.TaxStrikeIron.Configure", model));
        }