public async Task <IActionResult> PutLabel([FromRoute] int id, [FromBody] Label label) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != label.Id) { return(BadRequest()); } _context.Entry(label).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LabelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutItem([FromRoute] int id, [FromBody] Item item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != item.Id) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(CreatedAtAction("GetItem", new { id = item.Id }, item)); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }