public ActionResult Save(CreateQuizViewModel model) { UserAns obj = new UserAns { UserId = model.UserId, QuestionId = model.question.Id, Answer = model.answer }; _context.UserAns.Add(obj); _context.SaveChanges(); return(RedirectToAction("CreateQuiz", new { uid = model.UserId, id = ++model.question.Id })); }
//displays the question and the potential answers then adds the user's input to the property UserAns public override void DisplayQuestions() { foreach (KeyValuePair <string, List <string> > pair in Listings) { Console.WriteLine("--------------------------------------------------------------------------------------\n"); Console.WriteLine(">> " + pair.Key + " (or press enter to exit)" + "\n"); //int i = 1; for (int i = 0; i < pair.Value.Count; i++) { Console.WriteLine(i + 1 + " - " + pair.Value[i]); } Console.WriteLine("\n--------------------------------------------------------------------------------------"); int input = int.Parse(Validator(1)); UserAns.Add(input); } }