Exemplo n.º 1
0
 public ActionResult Index(QuestionCoding model)
 {
     if (model.AuthorStudentId > 0)
     {
         return(RedirectToAction("GetNextQuestion", new { studentId = model.AuthorStudentId }));
     }
     else
     {
         return(View());
     }
 }
Exemplo n.º 2
0
        public ActionResult GetNextQuestion(GetNextQuestionViewModel vm)
        {
            //add coding
            QuestionCoding coding = new QuestionCoding()
            {
                AuthorStudentId = vm.StudentId,
                PostId          = vm.Post.Id,
                IsQuestion      = vm.IsQuestion,
            };

            Db.QuestionCodings.Add(coding);

            //update response count
            QuestionResponseCount count = Db.QuestionResponseCounts.Where(c => c.ContentId == vm.Post.Id).FirstOrDefault();

            count.Count++;
            Db.Entry(count).State = System.Data.Entity.EntityState.Modified;
            Db.SaveChanges();
            return(RedirectToAction("GetNextQuestion", new { studentId = vm.StudentId }));
        }