// GET: TopicQuestions/Create public IActionResult Create(int? id) { ViewBag.TopicList = _context.Topics.ToList(); ViewBag.TopicId = id; TopicQuestion topicQuestion = new TopicQuestion(); topicQuestion.IsActive = true; return View(topicQuestion); }
public IActionResult Create(TopicQuestion topicQuestion) { if (ModelState.IsValid) { // Initilize some statistics for this topic questions topicQuestion.TotalTime = new System.TimeSpan(0, 0, 0); topicQuestion.TimesAnswered = 0; topicQuestion.ASelected = 0; topicQuestion.BSelected = 0; topicQuestion.CSelected = 0; topicQuestion.DSelected = 0; _context.TopicQuestions.Add(topicQuestion); _context.SaveChanges(); return RedirectToAction("Details", new { id = topicQuestion.TopicQuestionId }); } ViewBag.TopicList = _context.Topics.ToList(); return View(topicQuestion); }
public IActionResult Edit(TopicQuestion topicQuestion) { if (ModelState.IsValid) { _context.Update(topicQuestion); _context.SaveChanges(); return RedirectToAction("Details", new { id = topicQuestion.TopicQuestionId }); } ViewBag.TopicList = _context.Topics.ToList(); return View(topicQuestion); }