public ActionResult SaveLimitedBuyArea(int productId, string AreaID, int AreaType) { if (string.IsNullOrEmpty(AreaID)) { return Json(new AjaxResponse { State = 0, Message = "限购区域不能为空" }); } var model = new Product_LimitedBuy_Area { ProductID = productId, AreaID = AreaID, AreaType = AreaType }; var ProductLimitedBuyAreaService = new ProductLimitedBuyAreaService(); if (ProductLimitedBuyAreaService.SelectByProductId(productId).FirstOrDefault() != null) { if (ProductLimitedBuyAreaService.UpdateByProductId(AreaID, productId) > 0) { return Json(new AjaxResponse { State = 1, Message = "修改成功" }); } } else { if (ProductLimitedBuyAreaService.Insert(model) > 0) return Json(new AjaxResponse { State = 1, Message = "添加成功" }); } return Json(new AjaxResponse { State = 0, Message = "操作失败" }); }
public ActionResult BatchAddLimitedArea(string batchId, string content) { var ProductLimitedBuyAreaService = new ProductLimitedBuyAreaService(); if (string.IsNullOrEmpty(batchId) && string.IsNullOrEmpty(content)) { return Json(new AjaxResponse { State = 0, Message = "请选择商品或地区" }); } if (!string.IsNullOrEmpty(batchId)) { string[] strId = batchId.Split(','); var model = new Product_LimitedBuy_Area(); foreach (var s in strId) { if (ProductLimitedBuyAreaService.SelectByProductId(int.Parse(s)).FirstOrDefault() != null) { ProductLimitedBuyAreaService.UpdateByProductId(content, int.Parse(s)); } else { model.ProductID = int.Parse(s); model.AreaID = content; model.AreaType = 1; ProductLimitedBuyAreaService.Insert(model); } } } return Json(new AjaxResponse { State = 1, Message = "设置成功" }); }