/// <summary> /// 保存 /// </summary> /// <param name="theData">保存的数据</param> public ActionResult SaveData(product theData, List <product_date> listProductDate) { //校验价格是否亏本 if (!_productBusiness.PaymentAmount(theData)) { return(Error("价格异常!请检查产品价格及营销价格")); } if (theData.Id == 0) { theData.enable_flag = "1"; theData.special_status = 3; theData.create_by = Operator.UserId; theData.create_time = DateTime.Now.ToCstTime(); _productBusiness.AddData(theData); } else { theData.update_by = Operator.UserId; theData.update_time = DateTime.Now.ToCstTime(); _productBusiness.UpdateData(theData); } var addProductDate = new List <product_date>(); var updateProductDate = new List <product_date>(); var teamlist = new List <team>(); //保存或更新开团日期 foreach (var item in listProductDate) { item.product_id = theData.Id; if (item.product_date_id == 0) { addProductDate.Add(item); teamlist.Add(new team() { product_id = theData.Id, start_time = item.open_date, status = 1 }); } else { updateProductDate.Add(item); } } _product_dateBusiness.Insert(addProductDate); _product_dateBusiness.Update(updateProductDate); _teamBusiness.Insert(teamlist); return(Success()); }
/// <summary> /// 保存 /// </summary> /// <param name="theData">保存的数据</param> public ActionResult SaveData(product theData, List <product_date> listProductDate, List <product_Introduction> datalistIntroduction) { //校验价格是否亏本 if (!_productBusiness.PaymentAmount(theData)) { return(Error("价格异常!请检查产品价格及营销价格")); } var supplier = _dictionaryBusiness.GetTheData(theData.supplier); if (supplier == null)//创建供应商 { var su = new dictionary() { Id = Guid.NewGuid().ToSequentialGuid(), code = "supplier", name = theData.supplier, sort = 0, enable_flag = "1" }; _dictionaryBusiness.AddData(su); theData.supplier = su.Id; } if (theData.Id == 0) { theData.enable_flag = "1"; theData.special_status = 0; theData.create_by = Operator.UserId; theData.create_time = DateTime.Now.ToCstTime(); _productBusiness.AddData(theData); } else { theData.update_by = Operator.UserId; theData.update_time = DateTime.Now.ToCstTime(); _productBusiness.UpdateData(theData); } var addIntroductions = new List <product_Introduction>(); foreach (var item in datalistIntroduction) { if (item.Id.IsNullOrEmpty()) { addIntroductions.Add(new product_Introduction() { Id = Guid.NewGuid().ToSequentialGuid(), productId = theData.Id, days = item.days, title = item.title, scheduling = item.scheduling, stay = item.stay, food = item.food, create_by = Operator.UserId, create_time = DateTime.Now.ToCstTime() }); } else { var introduction = new product_Introduction() { Id = item.Id, days = item.days, title = item.title, scheduling = item.scheduling, stay = item.stay, food = item.food, update_by = Operator.UserId, update_time = DateTime.Now.ToCstTime() }; _product_IntroductionBusiness.UpdateAny(introduction, new List <string>() { "days", "title", "scheduling", "stay", "food", "update_by", "update_time" }); } } _product_IntroductionBusiness.Insert(addIntroductions); var addProductDate = new List <product_date>(); var updateProductDate = new List <product_date>(); var teamlist = new List <team>(); //保存或更新开团日期 foreach (var item in listProductDate) { item.product_id = theData.Id; if (item.product_date_id == 0) { addProductDate.Add(item); teamlist.Add(new team() { product_id = theData.Id, start_time = item.open_date, status = 1 }); } else { updateProductDate.Add(item); } } _product_dateBusiness.Insert(addProductDate); _product_dateBusiness.Update(updateProductDate); _teamBusiness.Insert(teamlist); return(Success()); }