public IActionResult DeleteConfirmed(int id) { AnswerMultipleChoice answerMultipleChoice = _answerMultipleChoiceManager.Get(id); _answerMultipleChoiceManager.Delete(answerMultipleChoice); return(BackToQuestion()); }
public IActionResult Edit(int id, [Bind("Answer,IsAnswerCorrect,Id")] AnswerMultipleChoiceViewModel answerMultipleChoiceViewModel) { if (id != answerMultipleChoiceViewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { AnswerMultipleChoice answerMultipleChoice = MapToAnswerMultipleChoice(answerMultipleChoiceViewModel); _answerMultipleChoiceManager.Update(answerMultipleChoice); } catch (DbUpdateConcurrencyException) { if (!AnswerMultipleChoiceExists(answerMultipleChoiceViewModel.Id)) { return(NotFound()); } else { throw; } } return(BackToQuestion()); } return(View()); }
//Mapping AnswerMultipleChoice to AnswerMultipleChoiceViewModel private AnswerMultipleChoiceViewModel MapToAnswerMultipleChoiceViewModel(AnswerMultipleChoice answerMultipleChoice) { return(new AnswerMultipleChoiceViewModel( answerMultipleChoice.Id, answerMultipleChoice.QuestionMultipleChoice, answerMultipleChoice.Answer, answerMultipleChoice.IsAnswerCorrect )); }
// GET: AnswerMultipleChoice/Edit/5 public IActionResult Edit(int?id) { if (id == null) { return(NotFound()); } AnswerMultipleChoice answerMultipleChoice = _answerMultipleChoiceManager.Get(id); if (answerMultipleChoice == null) { return(NotFound()); } else { AnswerMultipleChoiceViewModel answerMultipleChoiceViewModel = MapToAnswerMultipleChoiceViewModel(answerMultipleChoice); return(View(answerMultipleChoiceViewModel)); } }
public IActionResult Create([Bind("Answer,IsAnswerCorrect,Id,Question")] AnswerMultipleChoiceViewModel answerMultipleChoiceViewModel) { try { int?questionId = (int)TempData["questionId"]; answerMultipleChoiceViewModel.QuestionMultipleChoice = _questionManager.GetMultipleChoice(questionId); if (ModelState.IsValid) { AnswerMultipleChoice answerMultipleChoice = MapToAnswerMultipleChoice(answerMultipleChoiceViewModel); _answerMultipleChoiceManager.Add(answerMultipleChoice); } return(RedirectToAction("Details", "QuestionMultipleChoice", new { id = questionId })); } catch (Exception) { return(NotFound()); } }