public IHttpActionResult Postaccount(account account) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.accounts.Add(account); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = account.AccountId }, account); }
public IHttpActionResult Putaccount(int id, account account) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != account.AccountId) { return BadRequest(); } db.Entry(account).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!accountExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }