// PUT odata/Suppliers(5) public IHttpActionResult Put([FromODataUri] int key, Supplier supplier) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (key != supplier.Id) { return BadRequest(); } db.Entry(supplier).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SupplierExists(key)) { return NotFound(); } else { throw; } } return Updated(supplier); }
// POST odata/Suppliers public IHttpActionResult Post(Supplier supplier) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Suppliers.Add(supplier); db.SaveChanges(); return Created(supplier); }