Example #1
0
        public IActionResult InsertAnswer(int queryNumber, int questionNumber)
        {
            var username = User.Identity.Name.ToString();
            var user     = UserOptions.GetUser(username);
            var query    = QueryOptions.Load(user, queryNumber);
            var question = QuestionOptions.Load(query, questionNumber);

            QuestionOptions.AddAnswer(question);

            return(RedirectToAction("LoadAnswer", "Answer", new { queryNumber = question.QueryNumber, questionNumber = question.Number, answerNumber = question.Answers.Max(x => x.Number) }));
        }
Example #2
0
        public IActionResult AddAnswer(int queryNumber, int number, string answerName)
        {
            var username = User.Identity.Name.ToString();
            var user     = UserOptions.GetUser(username);
            var query    = QueryOptions.Load(user, queryNumber);

            query.Questions = query.Questions.OrderBy(q => q.Order).ToList();
            var question = QuestionOptions.Load(query, number);

            question.Answers = question.Answers.OrderBy(a => a.Order).ToList();

            QuestionOptions.AddAnswer(question, 0, answerName);

            return(RedirectToAction("LoadActiveQuery", new { queryID = queryNumber }));
        }