public async Task <IActionResult> Create([Bind("Id,QuestionText,CorrectAnswer,WrongAnswers,Score,ExamId,Row,Definition,Visibility")] Question question) { if (ModelState.IsValid) { _context.Add(question); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ExamId"] = new SelectList(_context.Exams, "Id", "Id", question.ExamId); return(View(question)); }
public async Task <IActionResult> Create([Bind("Id,CreatorId,ExamTitle")] Exam exam) { if (ModelState.IsValid) { _context.Add(exam); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CreatorId"] = new SelectList(_context.Users, "Id", "Id", exam.CreatorId); return(View(exam)); }
public async Task <IActionResult> Create([Bind("Id,Score,Answered,CorrectAnswer,QuestionId,UserId")] QuestionResult questionResult) { if (ModelState.IsValid) { _context.Add(questionResult); await _context.SaveChangesAsync(); 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)); }
public async Task <IActionResult> Create([Bind("Id,FullName,Password")] User user) { if (ModelState.IsValid) { using (var sha256 = SHA256.Create()) { // Send a sample text to hash. var hashedBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(user.Password)); // Get the hashed string. user.Password = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower(); } _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }