//查看已发布的问题 public ActionResult MyPublish() { MyPublishModel model = new MyPublishModel(); UserDao userdao = new UserDao(); User user = userdao.getById(int.Parse(Request.Cookies["Menber"].Values["ID"])); QuestionDao questiondao = new QuestionDao(); model.questions = questiondao.getByUser(user); TypeDao typedao = new TypeDao(); model.types = typedao.getTypeList(); return(View(model)); }
public ActionResult Index() { IndexModel model = new IndexModel(); TypeDao typedao = new TypeDao(); model.types = typedao.getTypeList(); QuestionDao questiondao = new QuestionDao(); model.questions = questiondao.getAll(0, 6); for (int i = 0; i < model.questions.Count; i++) { model.questions[i].optionData = questiondao.getOptionData(model.questions[i]).Replace(" ", "").Replace("\n", "").Replace("\t", "").Replace("\r", ""); model.questions[i].voteCount = questiondao.getVoteCount(model.questions[i]); } return(View(model)); }
//查看已投票的问题 public ActionResult MyVote() { MyVoteModel model = new MyVoteModel(); UserDao userdao = new UserDao(); User user = userdao.getById(int.Parse(Request.Cookies["Menber"].Values["ID"])); VoteDao votedao = new VoteDao(); List <Vote> votes = votedao.getByUser(user); QuestionDao questiondao = new Dao.QuestionDao(); model.questions = new List <Question>(); foreach (Vote v in votes) { Question q = v.queID; model.questions.Add(q); } TypeDao typedao = new TypeDao(); model.types = typedao.getTypeList(); return(View(model)); }