public IHttpActionResult PutSupplier(int id, Supplier supplier) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != supplier.Id) { return BadRequest(); } db.Entry(supplier).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SupplierExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostSupplier(Supplier supplier) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Suppliers.Add(supplier); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = supplier.Id }, supplier); }