public async Task <IActionResult> PutCooperTest([FromRoute] int id, [FromBody] CooperTest cooperTest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cooperTest.Id) { return(BadRequest()); } _context.Entry(cooperTest).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CooperTestExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostCooperTest([FromBody] CooperTest cooperTest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CooperTests.Add(cooperTest); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCooperTest", new { id = cooperTest.Id }, cooperTest)); }
public async Task <IActionResult> AddorEdit([Bind("TestID,TestName")] CooperTest cooperTest) { if (ModelState.IsValid) { if (cooperTest.TestID == 0) { _context.Add(cooperTest); } else { _context.Update(cooperTest); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cooperTest)); }