public IHttpActionResult PutAccounts(int id, Accounts accounts) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != accounts.AccountID) { return BadRequest(); } db.Entry(accounts).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AccountsExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostAccounts(Accounts accounts) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Accounts.Add(accounts); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = accounts.AccountID }, accounts); }