Esempio n. 1
0
        //话题下的全部问题,时间排序
        public ActionResult all(int id)//topic id
        {
            TopicAllModel tm = new TopicAllModel();

            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 <TopicAllQuestion>();
            for (int i = 0; i < info.Count(); i++)
            {
                for (var j = 0; j < info[i].question.Count(); j++)
                {
                    TopicAllQuestion taq = new TopicAllQuestion();
                    taq.topic    = info[i].topic;
                    taq.question = info[i].question[j];
                    taq.timespan = model.getTimeSpan(taq.question.QTime);
                    tm.question.Add(taq);
                }
            }
            tm.question = model.orderByQTime(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));
        }
Esempio n. 2
0
        //按照时间排序
        public List <TopicAllQuestion> orderByQTime(List <TopicAllQuestion> info)
        {
            TopicAllQuestion temp;

            for (int i = 0; i < info.Count(); i++)
            {
                for (int j = info.Count() - 1; j > i; j--)
                {
                    if (info[j].question.QTime.ToOADate() > info[j - 1].question.QTime.ToOADate())
                    {
                        temp        = new TopicAllQuestion();
                        temp        = info[j];
                        info[j]     = info[j - 1];
                        info[j - 1] = temp;
                    }
                }
            }
            return(info);
        }
Esempio n. 3
0
        //topic id
        //话题下的全部问题,时间排序
        public ActionResult all(int id)
        {
            TopicAllModel tm = new TopicAllModel();
            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<TopicAllQuestion>();
            for (int i = 0; i < info.Count(); i++)
            {
                for (var j = 0; j < info[i].question.Count(); j++)
                {
                    TopicAllQuestion taq = new TopicAllQuestion();
                    taq.topic = info[i].topic;
                    taq.question = info[i].question[j];
                    taq.timespan = model.getTimeSpan(taq.question.QTime);
                    tm.question.Add(taq);
                }
            }
            tm.question = model.orderByQTime(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);
        }
Esempio n. 4
0
 //按照时间排序
 public List<TopicAllQuestion> orderByQTime(List<TopicAllQuestion> info)
 {
     TopicAllQuestion temp;
     for (int i = 0; i < info.Count(); i++)
     {
         for (int j = info.Count() - 1; j > i; j--)
         {
             if (info[j].question.QTime.ToOADate() > info[j - 1].question.QTime.ToOADate())
             {
                 temp = new TopicAllQuestion();
                 temp = info[j];
                 info[j] = info[j - 1];
                 info[j - 1] = temp;
             }
         }
     }
     return info;
 }