public async Task <IActionResult> Edit(int id, [Bind("BoolAnswerId,Answer,QuestionId,CreationDate")] BoolAnswer boolAnswer) { if (id != boolAnswer.BoolAnswerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(boolAnswer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BoolAnswerExists(boolAnswer.BoolAnswerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["QuestionId"] = new SelectList(_context.Questions, "QuestionId", "QuestionId", boolAnswer.QuestionId); return(View(boolAnswer)); }
public async Task <IActionResult> CreateBool([Bind("BoolAnswerId,Answer,QuestionId,CreationDate")] BoolAnswer boolAnswer) { if (ModelState.IsValid) { _context.Add(boolAnswer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details), "Questions", new { id = boolAnswer.QuestionId })); } return(View(boolAnswer)); }
public async Task <IActionResult> CreateBoolAnswer([Bind("BoolAnswerId,Answer,QuestionId,CreationDate")] BoolAnswer boolAnswer) { if (ModelState.IsValid) { _context.Add(boolAnswer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details), "Questions", new { id = boolAnswer.QuestionId })); } // Can't add answer we return to the CreateAnswer page var model = new CreateAnswerViewModel { Question = boolAnswer.Question }; return(View("CreateAnswer", model)); }