public IHttpActionResult PutAddressDto(int id, AddressDto addressDto) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != addressDto.Id) { return BadRequest(); } db.Entry(addressDto).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AddressDtoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostAddressDto(AddressDto addressDto) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.AddressDtoes.Add(addressDto); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = addressDto.Id }, addressDto); }