public IHttpActionResult PutPayment(int id, Payment payment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != payment.Id) { return BadRequest(); } db.Entry(payment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PaymentExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostPayment(Payment payment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Payments.Add(payment); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = payment.Id }, payment); }