public async Task <IActionResult> PutTedItem([FromRoute] int id, [FromBody] TedItem tedItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tedItem.Id) { return(BadRequest()); } _context.Entry(tedItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TedItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostTedItem([FromBody] TedItem tedItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.TedItem.Add(tedItem); try { await _context.SaveChangesAsync(); } catch (Exception e) { int a = 0; } return(CreatedAtAction("GetTedItem", new { id = tedItem.Id }, tedItem)); }