public JsonResult AddOrEditOilBrandPhonePriority(OilBrandPhonePriorityModel model) { if (string.IsNullOrWhiteSpace(model.PhoneNumber) || string.IsNullOrWhiteSpace(model.Brand)) { return(Json(new { Status = false, Msg = "请填写推荐信息" })); } var manager = new BaoYangManager(); bool?isExistVehicle = DALBaoyang.IsRepeatOilBrandPhonePriority(model); if (isExistVehicle == true) { return(Json(new { Status = false, Msg = model.PhoneNumber + "存在重复数据" })); } bool?Result = model.PKID > 0 ? manager.EditOilBrandPhonePriority(model, User.Identity.Name) : manager.AddOilBrandPhonePriority(new List <OilBrandPhonePriorityModel> { model }, User.Identity.Name); if (Result == null) { return(Json(new { Status = false, Msg = "出现未知错误,请查看错误日志" })); } else if (Result == true) { return(Json(new { Status = true, Msg = "修改成功" })); } else { return(Json(new { Status = false, Msg = "修改失败" })); } }
public JsonResult MultAddOilBrandPhonePriority(List <string> phones, string brand) { if (phones == null || !phones.Any() || string.IsNullOrWhiteSpace(brand)) { return(Json(new { Status = false, Msg = "请填写推荐信息" })); } var manager = new BaoYangManager(); List <OilBrandPhonePriorityModel> models = new List <OilBrandPhonePriorityModel>(); var phoneList = phones.Distinct().ToList(); foreach (var phone in phoneList) { if (!string.IsNullOrWhiteSpace(phone)) { OilBrandPhonePriorityModel model = new OilBrandPhonePriorityModel { PKID = 0, PhoneNumber = phone, Brand = brand }; bool?isExistVehicle = DALBaoyang.IsRepeatOilBrandPhonePriority(model); if (isExistVehicle == true) { return(Json(new { Status = false, Msg = model.PhoneNumber + "存在重复数据" })); } models.Add(model); } } bool?Result = manager.AddOilBrandPhonePriority(models, User.Identity.Name); if (Result == null) { return(Json(new { Status = false, Msg = "出现未知错误,请查看错误日志" })); } else if (Result == true) { return(Json(new { Status = true, Msg = "添加成功" })); } else { return(Json(new { Status = false, Msg = "添加失败" })); } }