public IHttpActionResult GetOhters(string id) { results res = new results(); using (var db = new oucfreetalkEntities()) { var stu = db.students.FirstOrDefault(a => a.id == id); if (stu != null) { reStudent st = new reStudent(); st.id = stu.id; st.ifname = stu.ifname; st.nikename = stu.nikename; st.pic = stu.pic; st.ifsex = stu.ifsex; st.year = stu.year; st.ifemail = stu.ifemail; st.ifmobile = stu.ifmobile; st.exp = stu.exp; st.family = stu.family; st.ifbirth = stu.ifbirth; if (stu.ifemail) { st.email = stu.email; } if (stu.ifname) { st.name = stu.name; } if (stu.ifmobile) { st.mobile = stu.mobile; } if (stu.ifbirth) { st.birth = stu.birth; } if (stu.ifsex) { st.sex = stu.sex; } return(Ok(st)); } else { res.result = 0; return(Ok(res)); } } }
public IHttpActionResult Getmy() { results res = new results(); try { string sid = HttpContext.Current.Session["sid"].ToString(); using (var db = new oucfreetalkEntities()) { var stu = db.students.FirstOrDefault(a => a.id == sid); if (stu != null) { reStudent st = new reStudent(); st.id = stu.id; st.name = stu.name; st.nikename = stu.nikename; st.pic = stu.pic; st.ifsex = stu.ifsex; st.year = stu.year; st.ifemail = stu.ifemail; st.ifmobile = stu.ifmobile; st.exp = stu.exp; st.family = stu.family; st.ifbirth = stu.ifbirth; st.email = stu.email; st.ifname = stu.ifname; st.mobile = stu.mobile; st.birth = stu.birth; st.sex = stu.sex; return(Ok(st)); } else { res.result = 4; return(Ok(res)); } } } catch { res.result = 0; return(Ok(res)); } }