public IHttpActionResult Create(Item item) { if (!ModelState.IsValid) { return BadRequest(ModelState); } Context.Items.Add(item); Context.SaveChanges(); return Ok(); }
public IHttpActionResult Update(int id, Item item) { item.Id = id; if (!ModelState.IsValid) { return BadRequest(ModelState); } Context.Items.Attach(item); var entry = Context.Entry(item); entry.State = EntityState.Modified; Context.SaveChanges(); return Ok(); }