Example #1
0
 private static List<AnswerModel> PopulateAnswers(SqlDataReader reader)
 {
     var answerList = new List<AnswerModel>();
     while (reader.Read())
     {
         var answerModel = new AnswerModel
                               {
                                   Id = int.Parse(reader["id"].ToString()),
                                   answer = reader["answer"].ToString(),
                                   QuestionId = int.Parse(reader["question_id"].ToString())
                               };
         answerList.Add(answerModel);
     }
     return answerList;
 }
Example #2
0
        public ActionResult Create(AnswerModel collection)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid && Request["question_id"] != null)
                {

                    collection.QuestionId = int.Parse(Request["question_id"]);
                    collection.Save();

                    return RedirectToAction("Index", "question");
                }
                else
                {
                    return View();
                }
            }
            catch
            {
                return View();
            }
        }