示例#1
0
        //话题下的所有问题,动态,时间排序
        public ActionResult newest(int id)//topic id
        {
            TopicNewestModel tm = new TopicNewestModel();

            tm.myUser            = db.Users.Find(getCookie("id"));
            tm.topic             = new TopicPreNext();
            tm.topic.topic       = db.Topics.Find(id);
            tm.topic.fatherTopic = db.Topics.Find(tm.topic.topic.TFatherID);
            tm.topic.childTopic  = db.Topics.Where(t => t.TFatherID == id).ToList();

            tm.question = new List <TopicInfo>();
            TopicQuestion temp = model.getBestAnswerByTopic(tm.topic.topic);

            for (int i = 0; i < tm.topic.topic.QuestionNum; i++)
            {
                TopicInfo questionInfo = new TopicInfo();
                questionInfo.topic     = temp.topic;
                questionInfo.question  = temp.question[i];
                questionInfo.hotAnswer = temp.HotAnswer[i];
                questionInfo.hotUser   = temp.HotUser[i];
                tm.question.Add(questionInfo);
            }
            List <TopicQuestion> childQuestion = new List <TopicQuestion>();

            for (int i = 0; i < tm.topic.childTopic.Count(); i++)
            {
                temp = model.getBestAnswerByTopic(tm.topic.childTopic[i]);
                for (int j = 0; j < tm.topic.childTopic[i].QuestionNum; j++)
                {
                    TopicInfo questionInfo = new TopicInfo();
                    questionInfo.topic     = tm.topic.childTopic[i];
                    questionInfo.question  = temp.question[j];
                    questionInfo.hotUser   = temp.HotUser[j];
                    questionInfo.hotAnswer = temp.HotAnswer[j];
                    tm.question.Add(questionInfo);
                }
            }
            tm.question = model.orderByQTime(tm.question);

            for (int i = 0; i < tm.question.Count(); i++)
            {
                tm.question[i].timeSpan = model.getTimeSpan(tm.question[i].question.QTime);
            }

            IEnumerable <FollowTopic> IsFocus = db.FollowTopics.Where(a => a.FollowingTID == tm.topic.topic.TID).Where(b => b.FTUserID == tm.myUser.UID);

            if (IsFocus.Count() != 0)
            {
                ViewBag.flag = "focus";
            }
            else
            {
                ViewBag.flag = "nofocus";
            }
            return(View(tm));
        }
示例#2
0
        //topic id
        //话题下的所有问题,动态,时间排序
        public ActionResult newest(int id)
        {
            TopicNewestModel tm = new TopicNewestModel();
            tm.myUser = db.Users.Find(getCookie("id"));
            tm.topic = new TopicPreNext();
            tm.topic.topic = db.Topics.Find(id);
            tm.topic.fatherTopic = db.Topics.Find(tm.topic.topic.TFatherID);
            tm.topic.childTopic = db.Topics.Where(t => t.TFatherID == id).ToList();

            tm.question = new List<TopicInfo>();
            TopicQuestion temp = model.getBestAnswerByTopic(tm.topic.topic);

            for (int i = 0; i < tm.topic.topic.QuestionNum; i++)
            {
                TopicInfo questionInfo = new TopicInfo();
                questionInfo.topic = temp.topic;
                questionInfo.question = temp.question[i];
                questionInfo.hotAnswer = temp.HotAnswer[i];
                questionInfo.hotUser = temp.HotUser[i];
                tm.question.Add(questionInfo);
            }
            List<TopicQuestion> childQuestion = new List<TopicQuestion>();
            for (int i = 0; i < tm.topic.childTopic.Count(); i++)
            {
                temp = model.getBestAnswerByTopic(tm.topic.childTopic[i]);
                for (int j = 0; j < tm.topic.childTopic[i].QuestionNum; j++)
                {
                    TopicInfo questionInfo = new TopicInfo();
                    questionInfo.topic = tm.topic.childTopic[i];
                    questionInfo.question = temp.question[j];
                    questionInfo.hotUser = temp.HotUser[j];
                    questionInfo.hotAnswer = temp.HotAnswer[j];
                    tm.question.Add(questionInfo);
                }
            }
            tm.question = model.orderByQTime(tm.question);

            for (int i = 0; i < tm.question.Count(); i++)
            {
                tm.question[i].timeSpan = model.getTimeSpan(tm.question[i].question.QTime);
            }

            IEnumerable<FollowTopic> IsFocus = db.FollowTopics.Where(a => a.FollowingTID == tm.topic.topic.TID).Where(b => b.FTUserID == tm.myUser.UID);
            if (IsFocus.Count() != 0)
            {
                ViewBag.flag = "focus";
            }
            else
            {
                ViewBag.flag = "nofocus";
            }
            return View(tm);
        }