Beispiel #1
0
        public IActionResult AddAnswer(Answer a)
        {
            var db = new QuestionRepository(_conn);

            db.AddAnswer(a);
            //return Redirect($"/home/Question?questionId={a.QuestionId}"); //this works fine but using redirectotoaction
            return(RedirectToAction("Question", new { questionid = a.QuestionId }));
        }
        public IActionResult Answer(int UserId, string Text, int QuestionId)
        {
            var answer = new Answer
            {
                UserId     = UserId,
                Text       = Text,
                QuestionId = QuestionId
            };

            answer.DatePosted = DateTime.Now;
            var repos = new QuestionRepository(_connectionString);

            repos.AddAnswer(answer);
            return(Json(answer));
        }