public JsonResult DeleteQuestion(List <string> code) { if (code != null) { var bus = new QUESTION_BUS(); var busAnswer = new ANSWER_BUS(); foreach (string t in code) { var item = bus.GetByID(new QUESTION_OBJ.BusinessObjectID(t)); List <ANSWER_OBJ> lianswer = busAnswer.getAllBy(new fieldpara("QUESTIONCODE", t)); foreach (var itemAnswer in lianswer) { busAnswer.delete(itemAnswer._ID); } if (t != null) { bus.delete(item._ID); } } busAnswer.CloseConnection(); bus.CloseConnection(); } return(Json(new { ret = 0 }, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteAnswer(List <string> code) { var ret = 0; var error = false; if (code != null) { var bus = new ANSWER_BUS(); foreach (string t in code) { if (t != null) { var item = bus.GetByID(new ANSWER_OBJ.BusinessObjectID(t)); if (item == null) { ret = -1; error = true; continue; } if (ret >= 0) { ret = bus.delete(item._ID); } if (!error && ret < 0) { error = true; } } } bus.CloseConnection(); } ret = error ? -1 : 0; return(Json(new { ret }, JsonRequestBehavior.AllowGet)); }