public IHttpActionResult PostPaymentSupplier(PaymentSupplier paymentSupplier) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.PaymentSuppliers.Add(paymentSupplier); try { db.SaveChanges(); } catch (DbUpdateException) { if (PaymentSupplierExists(paymentSupplier.Payments_Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = paymentSupplier.Payments_Id }, paymentSupplier); }
public IHttpActionResult PutPaymentSupplier(int id, PaymentSupplier paymentSupplier) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != paymentSupplier.Payments_Id) { return BadRequest(); } db.Entry(paymentSupplier).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PaymentSupplierExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }