Exemplo n.º 1
0
        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
            });
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public void Save(ByWeightShippingRulesModel model)
 {
     var method = _service.GetById(model.ShippingMethodId);
     method.ShippingRateProviderData = JsonConvert.SerializeObject(model.Rules);
 }