public IHttpActionResult PutAccount(int id, Account account) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != account.AccountId) { return BadRequest(); } accountsDb.Update(account); try { accountsDb.Save(); } catch (DbUpdateConcurrencyException) { if (!AccountExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostAccount(Account account) { if (!ModelState.IsValid) { return BadRequest(ModelState); } accountsDb.Add(account); accountsDb.Save(); return CreatedAtRoute("DefaultApi", new { id = account.AccountId }, account); }