public IHttpActionResult PostSkill(Skill skill) { if (!ModelState.IsValid) { return BadRequest(ModelState); } // Ownership reassignment is not allows if (skill.OwnerIdentity != User.Identity.Name) return BadRequest(); db.Save(skill); return CreatedAtRoute("DefaultApi", new { id = skill.Id }, skill); }
public IHttpActionResult PutSkill(int id, Skill skill) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != skill.Id) { return BadRequest(); } // Ownership reassignment is not allows if (skill.OwnerIdentity != User.Identity.Name) return BadRequest(); using(var tx = db.BeginTransaction()) { db.SaveOrUpdate(skill); tx.Commit(); } return StatusCode(HttpStatusCode.NoContent); }