public IHttpActionResult PutContact(int id, Contacts contact) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != contact.ContactID) { return BadRequest(); } db.Entry(contact).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(id)) { return NotFound(); } else { throw; } } // return StatusCode(HttpStatusCode.NoContent); return Ok(contact); }
public IHttpActionResult PostContact(Contacts contact) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Contacts.Add(contact); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = contact.ContactID }, contact); }