public IHttpActionResult Postcustomer(customer customer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.customers.Add(customer); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = customer.CustomerId }, customer); }
public IHttpActionResult Putcustomer(int id, customer customer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != customer.CustomerId) { return BadRequest(); } db.Entry(customer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!customerExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }