public ReturnValue <PageInfo <QA_AnswerShow> > GetQuestionListByUserAnswer(int pagesize, int pageindex, int customersysno, int cate, string orderby) { int total = 0; DataTable m_dt = QA_AnswerBll.GetInstance().GetListByUser(pagesize, pageindex, customersysno, "", cate, false, orderby, ref total); List <QA_AnswerShow> ret = new List <QA_AnswerShow>(); PageInfo <QA_AnswerShow> rett = new PageInfo <QA_AnswerShow>(); if (m_dt == null || m_dt.Rows.Count == 0) { rett.List = ret; rett.Total = total; rett.HasNextPage = false; return(ReturnValue <PageInfo <QA_AnswerShow> > .Get200OK(rett)); } for (int i = 0; i < m_dt.Rows.Count; i++) { QA_AnswerShow tmp_quest = MapQA_AnswerShow(m_dt.Rows[i]); tmp_quest.QuestionTitle = m_dt.Rows[i]["QuestTitle"].ToString(); ret.Add(tmp_quest); } rett.List = ret; rett.Total = total; if (pagesize * pageindex >= total) { rett.HasNextPage = false; } else { rett.HasNextPage = true; } return(ReturnValue <PageInfo <QA_AnswerShow> > .Get200OK(rett)); }
public ReturnValue <PageInfo <QA_AnswerShow> > GetAnswerByQuest(int pagesize, int pageindex, int sysno) { int total = 0; DataTable m_dt = QA_AnswerBll.GetInstance().GetListByQuest(pagesize, pageindex, sysno, ref total); List <QA_AnswerShow> ret = new List <QA_AnswerShow>(); PageInfo <QA_AnswerShow> rett = new PageInfo <QA_AnswerShow>(); if (m_dt == null || m_dt.Rows.Count == 0) { rett.List = ret; rett.Total = total; rett.HasNextPage = false; return(ReturnValue <PageInfo <QA_AnswerShow> > .Get200OK(rett)); } for (int i = 0; i < m_dt.Rows.Count; i++) { QA_AnswerShow tmp_answer = MapQA_AnswerShow(m_dt.Rows[i]); USR_CustomerShow tmpu = new USR_CustomerShow(); USR_CustomerBll.GetInstance().GetModel(tmp_answer.CustomerSysNo).MemberwiseCopy(tmpu); tmp_answer.Customer = tmpu; DataTable tmp_dt = QA_CommentBll.GetInstance().GetListByAnswer(tmp_answer.SysNo); if (tmp_dt != null && tmp_dt.Rows.Count > 0) { List <QA_CommentShow> commentlist = new List <QA_CommentShow>(); for (int j = 0; j < tmp_dt.Rows.Count && j <= 3; j++) { QA_CommentShow tmp_comment = MapQA_CommentShow(tmp_dt.Rows[j]); USR_CustomerMaintain tmpuu = new USR_CustomerMaintain(); USR_CustomerBll.GetInstance().GetModel(tmp_comment.CustomerSysNo).MemberwiseCopy(tmpuu); tmp_comment.Customer = tmpuu; commentlist.Add(tmp_comment); } tmp_answer.TopComments = commentlist; tmp_answer.ToalComment = tmp_dt.Rows.Count; if (tmp_dt.Rows.Count > 3) { tmp_answer.HasMoreComment = true; } else { tmp_answer.HasMoreComment = false; } } ret.Add(tmp_answer); } rett.List = ret; rett.Total = total; if (pagesize * pageindex >= total) { rett.HasNextPage = false; } else { rett.HasNextPage = true; } return(ReturnValue <PageInfo <QA_AnswerShow> > .Get200OK(rett)); }
public QA_AnswerShow MapQA_AnswerShow(DataRow input) { QA_AnswerShow ret = new QA_AnswerShow(); if (input["Award"].ToString() != "") { ret.Award = int.Parse(input["Award"].ToString()); } ret.Context = input["Context"].ToString(); if (input["CustomerSysNo"].ToString() != "") { ret.CustomerSysNo = int.Parse(input["CustomerSysNo"].ToString()); } if (input["DR"].ToString() != "") { ret.DR = int.Parse(input["DR"].ToString()); } if (input["Hate"].ToString() != "") { ret.Hate = int.Parse(input["Hate"].ToString()); } if (input["Love"].ToString() != "") { ret.Love = int.Parse(input["Love"].ToString()); } if (input["QuestionSysNo"].ToString() != "") { ret.QuestionSysNo = int.Parse(input["QuestionSysNo"].ToString()); } if (input["SysNo"].ToString() != "") { ret.SysNo = int.Parse(input["SysNo"].ToString()); } ret.Title = input["Title"].ToString(); if (input["TS"].ToString() != "") { ret.TS = DateTime.Parse(input["TS"].ToString()).ToMilliSecondsFrom1970L() / 1000; } return(ret); }