public async Task <IActionResult> PutTest([FromRoute] int id, [FromBody] Test test) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != test.ID) { return(BadRequest()); } _context.Entry(test).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TestExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("QuestionId,Text")] Question question) { if (ModelState.IsValid) { _context.Add(question); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(question)); }