Beispiel #1
0
        public ActionResult SetupShippingCost()
        {
            ShopShippingCostModel model = new ShopShippingCostModel();

            if (GetCurrentShopId().HasValue)
            {
                int shopId = GetCurrentShopId().Value;
                IShopShippingCostBLL shippingCostBLL = BLLFactory <IShopShippingCostBLL> .GetBLL("ShopShippingCostBLL");

                var shippingCost = shippingCostBLL.GetEntity(s => s.ShopId == shopId);

                if (shippingCost != null)
                {
                    model.OrderExpense = shippingCost.OrderExpense;
                    model.Price        = shippingCost.Price;
                    model.Id           = shippingCost.Id;
                    model.IsFree       = shippingCost.IsFree == 1 ? true : false;
                }

                model.ShopId = shopId;

                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Beispiel #2
0
        public JsonResult SetupShippingCost(ShopShippingCostModel model)
        {
            JsonModel Jm = new JsonModel();

            if (ModelState.IsValid)
            {
                IShopShippingCostBLL shippingCostBLL = BLLFactory <IShopShippingCostBLL> .GetBLL("ShopShippingCostBLL");

                //如果存在更新,否则添加新的
                if (model.Id.HasValue)
                {
                    var shippingCost = shippingCostBLL.GetEntity(s => s.Id == model.Id);

                    shippingCost.OrderExpense = model.OrderExpense;
                    shippingCost.Price        = model.Price;
                    shippingCost.IsFree       = model.IsFree ? 1 : 0;

                    shippingCostBLL.Update(shippingCost);
                }
                else
                {
                    T_ShopShippingCost shippingCost = new T_ShopShippingCost();

                    shippingCost.ShopId       = model.ShopId;
                    shippingCost.OrderExpense = model.OrderExpense;
                    shippingCost.Price        = model.Price;
                    shippingCost.IsFree       = model.IsFree ? 1 : 0;

                    shippingCostBLL.Save(shippingCost);
                }

                Jm.Content = Property.Common.PropertyUtils.ModelToJsonString(model);
            }
            else
            {
                Jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }

            return(Json(Jm, JsonRequestBehavior.AllowGet));
        }