Exemplo n.º 1
0
 //添加一个问题
 public Question addQuestionByUser(Question question)
 {
     db.Questions.Add(question);
     User user = db.Users.Find(question.QUserID);
     user.UQuestionNum++;
     db.SaveChanges();
     return question;
 }
Exemplo n.º 2
0
 /*
 //某用户提了一个问题
 public Question addQuestion(Question question, int QUserID)
 {
     question.QUserID = QUserID;
     question.QState = "unknown";
     return question;
 }
 */
 //添加一个问题
 public void addQuestion(string content, string description, int UID)
 {
     Question q = new Question();
     q.QState = "unknown";
     q.QUserID = UID;
     q.QDescription = description;
     q.QContent = content;
     db.Questions.Add(q);
     User u = db.Users.Find(UID);
     u.UQuestionNum++;
     db.SaveChanges();
 }
Exemplo n.º 3
0
 public ActionResult answer()
 {
     int id = getCookie("id");
     if (id == -1) return RedirectToAction("index", "index");
     UserModel thisUser = model.getAllUserInfo(id);
     isFocus(thisUser.myUser.UID);
     List<Answer> a = thisUser.answers.ToList();
     List<Question> q = new List<Question>();
     for (int i = 0; i < a.Count(); i++)
     {
         Question temp = new Question();
         temp = db.Questions.Find(a[i].AQuestionID);
         q.Add(temp);
     }
     thisUser.questions = q.AsEnumerable();
     //显示people文件夹下的index页面
     return View(thisUser);
 }
Exemplo n.º 4
0
 //按照时间排序
 public List<Question> orderByQTime(List<Question> info)
 {
     Question temp;
     for (int i = 0; i < info.Count(); i++)
     {
         for (int j = info.Count() - 1; j > i; j--)
         {
             if (info[j].QTime.ToOADate() > info[j - 1].QTime.ToOADate())
             {
                 temp = new Question();
                 temp = info[j];
                 info[j] = info[j - 1];
                 info[j - 1] = temp;
             }
         }
     }
     return info;
 }
Exemplo n.º 5
0
        public ActionResult question()
        {
            int uID = getCookie("id");
            if (uID == -1) return RedirectToAction("index", "index");
            Question q = new Question();
            string c = Request.Form["QContent"];
            string d = Request.Form["QDescription"];
            string e = Request.Form["topicSelect"];
            List<Topic> topic = db.Topics.ToList();
            if (c != "")
            {
                int i;
                for (i = 0; i < topic.Count(); i++)
                {
                    if (e == topic[i].TContent)
                    {
                        q.QTopicType1 = i + 1;
                        topic[i].QuestionNum++;
                        break;
                    }
                }
                if (i >= topic.Count())
                    q.QTopicType1 = 5;
                if (model.searchWord(c))
                {
                    q.QState = "reject";
                    q.QContent = c;
                    if (d == "")
                        q.QDescription = null;
                    else
                        q.QDescription = d;
                    q.QUserID = uID;
                    //db.Questions.Add(q);
                    //db.SaveChanges();
                    model.sendMessage(uID, 1, "你的提问含有敏感词,拒绝发布", 3);
                    return RedirectToAction("inbox", "message", new { id = 1 });
                }
                else
                {

                    q.QUserID = uID;
                    q.QContent = c;
                    q.QDescription = d;
                    q.QState = "unknown";
                    db.Questions.Add(q);
                    User u = db.Users.Find(uID);
                    u.UQuestionNum++;
                    db.SaveChanges();
                    return RedirectToAction("show", new { id = q.QID });
                }
            }
            else
                return RedirectToAction("index", "index");
        }
Exemplo n.º 6
0
        public ActionResult _answer(string email)
        {
            User user = db.Users.FirstOrDefault(d => d.UEmail == email);
            isFocus(user.UID);
            UserModel thisUser = model.getAllUserInfo(user.UID);
            List<Answer> a = thisUser.answers.ToList();
            List<Question> q = new List<Question>();
            for (int i = 0; i < a.Count(); i++)
            {
                Question temp = new Question();
                temp = db.Questions.Find(a[i].AQuestionID);
                q.Add(temp);
            }
            thisUser.questions = q.AsEnumerable();

            //显示people文件夹下的index页面
            return View("answer", thisUser);
        }