public IHttpActionResult PostFence(Fence fence) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Fences.Add(fence); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = fence.ID }, fence); }
public void MarkAsModifiedFence(Fence item) { }
public void MarkAsModifiedFence(Fence item) { Entry(item).State = EntityState.Modified; }
public IHttpActionResult PutFence(int id, Fence fence) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != fence.ID) { return BadRequest(); } //db.Entry(fence).State = EntityState.Modified; db.MarkAsModifiedFence(fence); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!FenceExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }