//给List赋值 private List<Publish> initPublishList(List<Model.hp_publish> list) { List<Publish> newlist = new List<Publish>(); for (int i = 0; i < list.Count(); i++) { Publish publish = new Publish(list[i], true); newlist.Add(publish); } return newlist; }
public object GetIndexByIndex() { try { var model = entity.hp_publish.First(o => o.state == StringHelper.首页); Publish publish = new Publish(model); return publish; } catch (Exception e) { return null; } }
//形式三 返回首页公告 public string GetIndex() { string jsonstr = ""; try { var model = entity.hp_publish.First(o => o.state == StringHelper.首页); Publish publish = new Publish(model); jsonstr = ReturnJson.toJson("100", "成功", publish); } catch (Exception e) { jsonstr = ReturnJson.toJson("101", "失败", -1); } return jsonstr; }
//形式二 返回特定公告 public string GetById(int publish_id) { string jsonstr = ""; try { var model = entity.hp_publish.First(o=>o.id==publish_id); Publish publish = new Publish(model); jsonstr = ReturnJson.toJson("100", "成功", publish); } catch (Exception e) { jsonstr = ReturnJson.toJson("101", "失败", -1); } return jsonstr; }