public IHttpActionResult PutCustomerPayment(int id, CustomerPayment customerPayment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != customerPayment.Id) { return BadRequest(); } db.Entry(customerPayment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerPaymentExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCustomerPayment(CustomerPayment customerPayment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CustomerPayments.Add(customerPayment); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = customerPayment.Id }, customerPayment); }