public async Task <IActionResult> Edit(int id, [Bind("Id,QuestionText,CorrectAnswer,WrongAnswers,Score,ExamId,Row,Definition,Visibility")] Question question) { if (id != question.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(question); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionExists(question.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ExamId"] = new SelectList(_context.Exams, "Id", "Id", question.ExamId); return(View(question)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,Password")] User user) { if (id != user.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,CreatorId,ExamTitle")] Exam exam) { if (id != exam.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(exam); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExamExists(exam.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CreatorId"] = new SelectList(_context.Users, "Id", "Id", exam.CreatorId); return(View(exam)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Score,Answered,CorrectAnswer,QuestionId,UserId")] QuestionResult questionResult) { if (id != questionResult.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(questionResult); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionResultExists(questionResult.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["QuestionId"] = new SelectList(_context.Questions, "Id", "Id", questionResult.QuestionId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", questionResult.UserId); return(View(questionResult)); }