Ejemplo n.º 1
0
        // PUT: api/Hops/5
        //[ResponseType(typeof(void))]
        //public async Task<IHttpActionResult> PutHop(int id, Hop hop)
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return BadRequest(ModelState);
        //    }

        //    if (id != hop.ID)
        //    {
        //        return BadRequest();
        //    }

        //    db.Entry(hop).State = EntityState.Modified;

        //    try
        //    {
        //        await db.SaveChangesAsync();
        //    }
        //    catch (DbUpdateConcurrencyException)
        //    {
        //        if (!HopExists(id))
        //        {
        //            return NotFound();
        //        }
        //        else
        //        {
        //            throw;
        //        }
        //    }

        //    return StatusCode(HttpStatusCode.NoContent);
        //}

        //// POST: api/Hops
        //[ResponseType(typeof(Hop))]
        //public async Task<IHttpActionResult> PostHop(Hop hop)
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return BadRequest(ModelState);
        //    }

        //    db.Hops.Add(hop);
        //    await db.SaveChangesAsync();

        //    return CreatedAtRoute("DefaultApi", new { id = hop.ID }, hop);
        //}

        // DELETE: api/Hops/5
        //[ResponseType(typeof(Hop))]
        //public async Task<IHttpActionResult> DeleteHop(int id)
        //{
        //    Hop hop = await db.Hops.FindAsync(id);
        //    if (hop == null)
        //    {
        //        return NotFound();
        //    }

        //    db.Hops.Remove(hop);
        //    await db.SaveChangesAsync();

        //    return Ok(hop);
        //}

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }