public async Task<IHttpActionResult> PutAccount(int id, Account account) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != account.Id) { return BadRequest(); } db.Entry(account).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAccount(Account account) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Accounts.Add(account); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = account.Id }, account); }