예제 #1
0
        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)
 {
 }
예제 #3
0
 public void MarkAsModifiedFence(Fence item)
 {
     Entry(item).State = EntityState.Modified;
 }
예제 #4
0
        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);
        }