public async Task <IActionResult> PutAnswer([FromRoute] int id, [FromBody] Answer answer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != answer.Id) { return(BadRequest()); } _context.Entry(answer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnswerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Username,Password")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Create([Bind("Id,TestId,UserName,Score,WriteDate")] TestResult testResult) { if (ModelState.IsValid) { _context.Add(testResult); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TestId"] = new SelectList(_context.BillOfMaterials, "Id", "Id", testResult.TestId); return(View(testResult)); }
public async Task <IActionResult> Create([Bind("Id,TestId,Row,Definition,Visibility")] Question question) { if (ModelState.IsValid) { _context.Add(question); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TestId"] = new SelectList(_context.BillOfMaterials, "Id", "Id", question.TestId); return(View(question)); }
public async Task <IActionResult> Create([Bind("Id,QuestionId,Row,Score,Definition,Type")] Answer answer) { if (ModelState.IsValid) { _context.Add(answer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["QuestionId"] = new SelectList(_context.AwbuildVersion, "Id", "Id", answer.QuestionId); return(View(answer)); }
public async Task <IActionResult> Create([Bind("Id,CreatorId,TestName,MaxScore,WriteDate")] Test test) { if (ModelState.IsValid) { _context.Add(test); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CreatorId"] = new SelectList(_context.BusinessEntityAddress, "Id", "Id", test.CreatorId); return(View(test)); }