public HttpResponseMessage saveLost(dynamic l) { string companyId = l.companyId; string lost_content = l.lost_content; Object data; try { BLL.Lost lost = new BLL.Lost(); bool flag = false; flag = lost.EditLost(lost_content, companyId); if (flag) { data = new { success = true }; } else { data = new { success = false, backMsg = "更新失物招领信息失败" }; } } catch (Exception ex) { data = new { success = false, backMsg = "服务异常" }; } string str = @"select * from dbo.ls_lost"; DataTable dt = DBHelper.SqlHelper.GetDataTable(str); JavaScriptSerializer serializer = new JavaScriptSerializer(); string json = serializer.Serialize(data); return(new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") }); }
public HttpResponseMessage getLostInfo() { DataTable dt = new BLL.Lost().GetLostInfo(); Object data; if (dt.Rows.Count > 0) { List <lost> list = new List <lost>(); for (int i = 0; i < dt.Rows.Count; i++) { lost lost = new lost(); lost.id = dt.Rows[i]["id"].ToString(); lost.companyId = dt.Rows[i]["companyId"].ToString(); lost.lost_content = dt.Rows[i]["lost_content"].ToString(); lost.create_time = dt.Rows[i]["create_time"].ToString(); list.Add(lost); } data = new { success = true, backData = list }; } else { data = new { success = false, backMsg = "数据异常" }; } JavaScriptSerializer serializer = new JavaScriptSerializer(); string json = serializer.Serialize(data); return(new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") }); }
public HttpResponseMessage getCompanyLostInfo(string companyId) { DataTable dt = new BLL.Lost().GetCompanyLostInfo(companyId); Object data; if (dt.Rows.Count == 1) { lost lost = new lost(); lost.id = dt.Rows[0]["id"].ToString(); lost.companyId = dt.Rows[0]["companyId"].ToString(); lost.lost_content = dt.Rows[0]["lost_content"].ToString(); lost.create_time = dt.Rows[0]["create_time"].ToString(); data = new { success = true, backData = lost }; } else { data = new { success = false, backMsg = "数据异常" }; } JavaScriptSerializer serializer = new JavaScriptSerializer(); string json = serializer.Serialize(data); return(new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") }); }