public async Task<IHttpActionResult> PutBank(Guid id, Bank bank) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != bank.BankId) { return BadRequest(); } db.Entry(bank).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BankExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostBank(Bank bank) { if (!ModelState.IsValid) { return BadRequest(ModelState); } bank.BankId = Guid.NewGuid(); db.Banks.Add(bank); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (BankExists(bank.BankId)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = bank.BankId }, bank); }