Exemplo n.º 1
0
        //// GET: api/SubCategories
        //public IQueryable<SubCategory> GetSubCategories()
        //{
        //    return db.SubCategories;
        //}

        //// GET: api/SubCategories/5
        //[ResponseType(typeof(SubCategory))]
        //public IHttpActionResult GetSubCategory(int id)
        //{
        //    SubCategory subCategory = db.SubCategories.Find(id);
        //    if (subCategory == null)
        //    {
        //        return NotFound();
        //    }

        //    return Ok(subCategory);
        //}

        //// PUT: api/SubCategories/5
        //[ResponseType(typeof(void))]
        //public IHttpActionResult PutSubCategory(int id, SubCategory subCategory)
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return BadRequest(ModelState);
        //    }

        //    if (id != subCategory.SubCategoryId)
        //    {
        //        return BadRequest();
        //    }

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

        //    try
        //    {
        //        db.SaveChanges();
        //    }
        //    catch (DbUpdateConcurrencyException)
        //    {
        //        if (!SubCategoryExists(id))
        //        {
        //            return NotFound();
        //        }
        //        else
        //        {
        //            throw;
        //        }
        //    }

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

        //// POST: api/SubCategories
        //[ResponseType(typeof(SubCategory))]
        //public IHttpActionResult PostSubCategory(SubCategory subCategory)
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return BadRequest(ModelState);
        //    }

        //    db.SubCategories.Add(subCategory);

        //    try
        //    {
        //        db.SaveChanges();
        //    }
        //    catch (DbUpdateException)
        //    {
        //        if (SubCategoryExists(subCategory.SubCategoryId))
        //        {
        //            return Conflict();
        //        }
        //        else
        //        {
        //            throw;
        //        }
        //    }

        //    return CreatedAtRoute("DefaultApi", new { id = subCategory.SubCategoryId }, subCategory);
        //}

        //// DELETE: api/SubCategories/5
        //[ResponseType(typeof(SubCategory))]
        //public IHttpActionResult DeleteSubCategory(int id)
        //{
        //    SubCategory subCategory = db.SubCategories.Find(id);
        //    if (subCategory == null)
        //    {
        //        return NotFound();
        //    }

        //    db.SubCategories.Remove(subCategory);
        //    db.SaveChanges();

        //    return Ok(subCategory);
        //}
        #endregion

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