public IHttpActionResult PostPaymentType(PaymentType paymentType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.PaymentTypes.Add(paymentType); try { db.SaveChanges(); } catch (DbUpdateException) { if (PaymentTypeExists(paymentType.PaymentTypeId)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = paymentType.PaymentTypeId }, paymentType); }
public IHttpActionResult PutPaymentType(int id, PaymentType paymentType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != paymentType.PaymentTypeId) { return BadRequest(); } db.Entry(paymentType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PaymentTypeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }