public ActionResult ViewQuestion(int question, string Code) // { QuestionDBContext QDB = new QuestionDBContext(); List <Questions> qset = QDB.Questions.ToList <Questions>(); Questions ques = qset.Where(b => b.QID == question).First(); AnswerDBContext ADB = new AnswerDBContext(); // List <Answer> aset = ADB.Answers.ToList <Answer>(); // aset = aset.Where(a => a.QID == question).ToList <Answer>(); // aset = aset.OrderByDescending(a => Convert.ToDateTime(a.ADate)).ToList <Answer>(); // ViewBag.Answers = aset; // Object rating = db.SelectUserRating(question, LoginInfo.LoginUsername); // if (rating != null) { ViewBag.URating = (bool)rating; // } else { ViewBag.Rating = null; // } ViewBag.Reported = db.SelectUserReport(question, LoginInfo.LoginUsername); ViewBag.Question = ques; Answer answer = new Answer(); answer.QID = question; ViewBag.course = Code; return(View(answer)); }
public ActionResult ViewQuestions(string Code) { QuestionDBContext DB = new QuestionDBContext(); LoginInfo.Course = Code; List <Questions> set = DB.Questions.ToList <Questions>(); set = set.Where(b => b.CourseID == LoginInfo.Course).ToList <Questions>(); set = set.OrderByDescending(b => Convert.ToDateTime(b.QDate)).ToList <Questions>(); // ViewBag.list = set; ViewBag.course = Code; return(View()); }