public IHttpActionResult PostMemberShipType(MemberShipType memberShipType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.MemberShipType.Add(memberShipType); try { db.SaveChanges(); } catch (DbUpdateException) { if (MemberShipTypeExists(memberShipType.GuestRating)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = memberShipType.GuestRating }, memberShipType); }
public IHttpActionResult PutMemberShipType(int id, MemberShipType memberShipType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != memberShipType.GuestRating) { return BadRequest(); } db.Entry(memberShipType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MemberShipTypeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }