public async Task <IActionResult> Edit(int id, [Bind("QuestionId,Answer,CorrectAnswer,Id")] Answers answers) { if (id != answers.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(answers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnswersExists(answers.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } //ViewData["QuestionId"] = new SelectList(_context.Questions, "Id", "Id", answers.QuestionId); ViewData["QuestionName"] = new SelectList(_context.Questions, "Id", "Question", answers.QuestionId); return(View(answers)); }
public async Task <IActionResult> Edit(int id, [Bind("CategoryId,Question,PointValue,Id")] Questions questions) { if (id != questions.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(questions); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionsExists(questions.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", questions.CategoryId); return(View(questions)); }
public async Task <IActionResult> Edit(int id, [Bind("Name,Active,Id")] Categories categories) { if (id != categories.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(categories); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoriesExists(categories.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(categories)); }
public async Task <IActionResult> Complete(int id) { try { var answer = await _context.Answers.FirstOrDefaultAsync(x => x.AnswerId == id); if (answer == null) { return(NotFound()); } answer.HasBeenRead = true; _context.Update(answer); await _context.SaveChangesAsync(); return(Ok()); } catch (Exception ex) { _logger.LogError(ex, $"An exception occurred in {MethodBase.GetCurrentMethod().Name}"); return(StatusCode(StatusCodes.Status500InternalServerError)); } }