public HttpResponseMessage Delete_tblFWContact(Delete_tblFWContact_Info info) { string result = string.Empty; List <tblFWContact> list = new List <tblFWContact>(); int result2 = 0; try { using (LAPContext db = new LAPContext()) { list = (from x in db.tblFWContact where info.IDList.Contains(x.fldAutoID) select x).ToList(); db.tblFWContact.RemoveRange(list); result2 = db.SaveChanges(); } if (result2 > 0) { result = rule.JsonStr("ok", "", "删除了" + result2 + "条数据"); } else { result = rule.JsonStr("nodata", "没有可删除的数据!", ""); } } catch (Exception e) { result = rule.JsonStr("error", e.Message, ""); } return(new HttpResponseMessage { Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json") }); }
public HttpResponseMessage AddOrUpdate_tblFWContact(AddOrUpdate_tblFWContact_Info info) { string result = string.Empty; tblFWContact wc = new tblFWContact(); int result2 = 0; try { using (LAPContext db = new LAPContext()) { wc.fldAutoID = info.fldAutoID; wc.fldSTName = info.fldSTName; wc.fldName = info.fldName; wc.fldTittle = info.fldTittle; wc.fldWork = info.fldWork; wc.fldTel = info.fldTel; wc.fldQQ = info.fldQQ; wc.fldRemark = info.fldRemark; db.tblFWContact.AddOrUpdate(wc); result2 = db.SaveChanges(); } if (result2 > 0) { result = rule.JsonStr("ok", "", "新建成功!ID为:" + wc.fldAutoID); } else { result = rule.JsonStr("nodata", "未知错误!", ""); } } catch (Exception e) { result = rule.JsonStr("error", e.Message, ""); } return(new HttpResponseMessage { Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json") }); }