public IHttpActionResult PostMember(Member member) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Members.Add(member); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = member.Id }, member); }
public IHttpActionResult PutMember(int id, Member member) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != member.Id) { return BadRequest(); } db.Entry(member).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MemberExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }