コード例 #1
0
ファイル: ConfigController.cs プロジェクト: Kooboo/Ecommerce
        public void Save(ByWeightShippingRulesModel model)
        {
            var method = _service.Find(model.ShippingMethodId);
            var rules = model.Rules.Select(r => new ByWeightShippingRule
            {
                FromWeight = Convert.ToDecimal(r.FromWeight),
                ToWeight = Convert.ToDecimal(r.ToWeight),
                PriceUnit = (ShippingPriceUnit)Enum.Parse(typeof(ShippingPriceUnit), r.PriceUnit),
                ShippingPrice = Convert.ToDecimal(r.ShippingPrice)
            })
            .ToList();

            method.UpdateShippingRateProviderConfig(new ByWeightShippingRateProviderConfig
            {
                Rules = rules
            });
        }
コード例 #2
0
ファイル: ConfigController.cs プロジェクト: Wipcore/Ecommerce
        public ActionResult Load(int methodId)
        {
            var method = _service.GetById(methodId);
            var rules = new List<ByWeightShippingRuleModel>();

            if (!String.IsNullOrWhiteSpace(method.ShippingRateProviderData))
            {
                rules = JsonConvert.DeserializeObject<List<ByWeightShippingRuleModel>>(method.ShippingRateProviderData);
            }

            var model = new ByWeightShippingRulesModel
            {
                ShippingMethodId = methodId,
                Rules = rules
            };

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
ファイル: ConfigController.cs プロジェクト: Kooboo/Ecommerce
        public ActionResult Load(int methodId)
        {
            var method = _service.Find(methodId);
            var config = method.LoadShippingRateProviderConfig<ByWeightShippingRateProviderConfig>() ?? new ByWeightShippingRateProviderConfig();
            var ruleModels = config.Rules.Select(r => new ByWeightShippingRuleModel
            {
                FromWeight = r.FromWeight.ToString(),
                ToWeight = r.ToWeight.ToString(),
                ShippingPrice = r.ShippingPrice.ToString(),
                PriceUnit = r.PriceUnit.ToString()
            })
            .ToList();

            var model = new ByWeightShippingRulesModel
            {
                ShippingMethodId = methodId,
                Rules = ruleModels
            };

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #4
0
ファイル: ConfigController.cs プロジェクト: Wipcore/Ecommerce
 public void Save(ByWeightShippingRulesModel model)
 {
     var method = _service.GetById(model.ShippingMethodId);
     method.ShippingRateProviderData = JsonConvert.SerializeObject(model.Rules);
 }