public async Task<IHttpActionResult> PutAddress(int id, Address address) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != address.Id) { return BadRequest(); } db.Entry(address).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAddress(Address address) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Addresses.Add(address); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = address.Id }, address); }