public IHttpActionResult PutTransaction(string id, Transaction transaction) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != transaction.Reference) { return BadRequest(); } try { rep.Update(id, transaction); } catch (DbUpdateConcurrencyException) { if (!rep.TransactionExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostTransaction(Transaction transaction) { if (!ModelState.IsValid) { return BadRequest(ModelState); } rep.Add(transaction); return CreatedAtRoute("DefaultApi", new { id = transaction.Reference }, transaction); }