Exemplo n.º 1
0
        //话题下的精品回答
        public ActionResult StarQuestion(int id)//topic id
        {
            TopicStarModel tm = new TopicStarModel();

            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();

            List <TopicQuestion> info = new List <TopicQuestion>();

            info.Add(model.getBestAnswerByTopic(tm.topic.topic));
            for (int i = 0; i < tm.topic.childTopic.Count(); i++)
            {
                info.Add(model.getBestAnswerByTopic(tm.topic.childTopic[i]));
            }

            tm.question = new List <TopicInfo>();
            for (int i = 0; i < info.Count(); i++)
            {
                for (var j = 0; j < info[i].question.Count(); j++)
                {
                    if (info[i].HotAnswer[j].AUpvoteNum > 0)
                    {
                        TopicInfo tq = new TopicInfo();
                        tq.topic     = info[i].topic;
                        tq.question  = info[i].question[j];
                        tq.hotUser   = info[i].HotUser[j];
                        tq.hotAnswer = info[i].HotAnswer[j];
                        tq.timeSpan  = model.getTimeSpan(info[i].question[j].QTime);
                        tm.question.Add(tq);
                    }
                }
            }
            tm.question = model.orderByAUpvoteNum(tm.question);

            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));
        }
Exemplo n.º 2
0
        //获得某个话题的精华回答
        //参数:登陆用户id, 话题topicId
        public List <TopicInfo> getStarQuestion(int id, int topicID)
        {
            TopicStarModel tm = new TopicStarModel();

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

            List <TopicQuestion> info = new List <TopicQuestion>();

            info.Add(getBestAnswerByTopic(tm.topic.topic));
            //for (int i = 0; i < tm.topic.childTopic.Count(); i++)
            // {
            //    info.Add(getBestAnswerByTopic(tm.topic.childTopic[i]));
            // }
            tm.question = new List <TopicInfo>();
            for (int i = 0; i < info.Count(); i++)
            {
                for (var j = 0; j < info[i].question.Count(); j++)
                {
                    if (info[i].HotAnswer[j].AUpvoteNum > 1)
                    {
                        TopicInfo tq = new TopicInfo();
                        tq.topic     = info[i].topic;
                        tq.question  = info[i].question[j];
                        tq.hotUser   = info[i].HotUser[j];
                        tq.hotAnswer = info[i].HotAnswer[j];
                        tq.timeSpan  = getTimeSpan(info[i].question[j].QTime);
                        tm.question.Add(tq);
                    }
                }
            }
            return(tm.question);
        }
Exemplo n.º 3
0
        //获得某个话题的精华回答
        //参数:登陆用户id, 话题topicId
        public List<TopicInfo> getStarQuestion(int id, int topicID)
        {
            TopicStarModel tm = new TopicStarModel();
            tm.myUser = db.Users.Find(id);
            tm.topic = new TopicPreNext();
            tm.topic.topic = db.Topics.Find(topicID);
            tm.topic.fatherTopic = db.Topics.Find(tm.topic.topic.TFatherID);
            tm.topic.childTopic = db.Topics.Where(t => t.TFatherID == id).ToList();

            List<TopicQuestion> info = new List<TopicQuestion>();
            info.Add(getBestAnswerByTopic(tm.topic.topic));
            //for (int i = 0; i < tm.topic.childTopic.Count(); i++)
               // {
            //    info.Add(getBestAnswerByTopic(tm.topic.childTopic[i]));
               // }
            tm.question = new List<TopicInfo>();
            for (int i = 0; i < info.Count(); i++)
            {
                for (var j = 0; j < info[i].question.Count(); j++)
                {
                    if (info[i].HotAnswer[j].AUpvoteNum > 1)
                    {
                        TopicInfo tq = new TopicInfo();
                        tq.topic = info[i].topic;
                        tq.question = info[i].question[j];
                        tq.hotUser = info[i].HotUser[j];
                        tq.hotAnswer = info[i].HotAnswer[j];
                        tq.timeSpan = getTimeSpan(info[i].question[j].QTime);
                        tm.question.Add(tq);
                    }
                }
            }
            return tm.question;
        }
Exemplo n.º 4
0
        //topic id
        //话题下的精品回答
        public ActionResult StarQuestion(int id)
        {
            TopicStarModel tm = new TopicStarModel();
            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();

            List<TopicQuestion> info = new List<TopicQuestion>();
            info.Add(model.getBestAnswerByTopic(tm.topic.topic));
            for (int i = 0; i < tm.topic.childTopic.Count(); i++)
            {
                info.Add(model.getBestAnswerByTopic(tm.topic.childTopic[i]));
            }

            tm.question = new List<TopicInfo>();
            for (int i = 0; i < info.Count(); i++)
            {
                for (var j = 0; j < info[i].question.Count(); j++)
                {
                    if (info[i].HotAnswer[j].AUpvoteNum > 0)
                    {
                        TopicInfo tq = new TopicInfo();
                        tq.topic = info[i].topic;
                        tq.question = info[i].question[j];
                        tq.hotUser = info[i].HotUser[j];
                        tq.hotAnswer = info[i].HotAnswer[j];
                        tq.timeSpan = model.getTimeSpan(info[i].question[j].QTime);
                        tm.question.Add(tq);
                    }
                }
            }
            tm.question = model.orderByAUpvoteNum(tm.question);

            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);
        }