public HttpResponseMessage saveHealth(dynamic s) { string id = s.id; string companyId = s.companyId; string health_cover = s.health_cover; string health_title = s.health_title; string health_desc = s.health_desc; string health_content = s.health_content; Object data; try { BLL.handleHealth health = new BLL.handleHealth(); bool flag = false; if (string.IsNullOrEmpty(id)) { flag = health.AddHealth(companyId, health_cover, health_title, health_desc, health_content); } else { flag = health.EditHealth(id, companyId, health_cover, health_title, health_desc, health_content); } if (flag) { data = new { success = true }; } else { data = new { success = false, backMsg = "保存信息失败" }; } } catch (Exception ex) { 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 getLiveList() { DataTable dt = new BLL.handleHealth().GetLiveList(); Object data; if (dt.Rows.Count >= 0) { List <live> list = new List <live>(); for (int i = 0; i < dt.Rows.Count; i++) { live live = new live(); live.id = dt.Rows[i]["id"].ToString(); live.companyId = dt.Rows[i]["companyId"].ToString(); live.live_cover = dt.Rows[i]["live_cover"].ToString(); live.live_title = dt.Rows[i]["live_title"].ToString(); live.live_desc = dt.Rows[i]["live_desc"].ToString(); live.live_content = dt.Rows[i]["live_content"].ToString(); live.create_time = dt.Rows[i]["create_time"].ToString(); list.Add(live); } 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 delLive(dynamic d) { string id = d.id; object data = new object(); try { BLL.handleHealth health = new BLL.handleHealth(); bool flag = false; flag = health.DelLive(id); if (flag) { data = new { success = true }; } else { data = new { success = false, backMsg = "删除动态失败" }; } } catch (Exception ex) { 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 getHealthDetail(string id) { DataTable dt = new BLL.handleHealth().GetHealthDetail(id); Object data; if (dt.Rows.Count == 1) { health health = new health(); health.id = dt.Rows[0]["id"].ToString(); health.companyId = dt.Rows[0]["companyId"].ToString(); health.health_cover = dt.Rows[0]["health_cover"].ToString(); health.health_title = dt.Rows[0]["health_title"].ToString(); health.health_desc = dt.Rows[0]["health_desc"].ToString(); health.health_content = dt.Rows[0]["health_content"].ToString(); health.create_time = dt.Rows[0]["create_time"].ToString(); data = new { success = true, backData = health }; } 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") }); }