public async Task <IActionResult> Edit(int id, [Bind("QuestionId,Text")] Question question) { if (id != question.QuestionId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(question); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionExists(question.QuestionId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(question)); }
public IActionResult Put([FromBody] Question question) { if (question == null) { return(BadRequest()); } if (!db.Questions.Any(x => x.Id == question.Id)) { return(NotFound()); } db.Update(question); db.SaveChanges(); return(Ok(question)); }