コード例 #1
0
        public IActionResult InsertDataP1(TestListingModel tmodel)
        {
            if (tmodel.Answers != null)
            {
                // -d HACK: delete the pre-loaded entries for this sessionId. ANSWER == 0
                _answers.DeleteAllBySessionId(TempData["SessionId"].ToString());

                //add to Survey table
                for (int i = 1; i <= tmodel.Answers.Count(); i++)
                {
                    var question = _questions.Get(tmodel.Answers[i - 1].QMaster.Id);

                    var newSurvey = new Survey
                    {
                        SessionId = TempData["SessionId"].ToString(),
                        QMaster   = question,
                        Answer    = tmodel.Answers[i - 1].Answer
                    };
                    _answers.Add(newSurvey);
                }
            }

            TempData.Keep();
            return(RedirectToAction("Index3", "Tests"));
        }