public IHttpActionResult PostProduct(Product product)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Products.Add(product);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = product.ProductId }, product);
        }
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != product.ProductId)
            {
                return BadRequest();
            }

               // db.Entry(product).State = EntityState.Modified;
            db.MarkAsModified(product);

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

            return StatusCode(HttpStatusCode.NoContent);
        }
 public void Add(Product b)
 {
     context.Products.Add(b);
     context.SaveChanges();
 }
 public void Edit(Product b)
 {
     context.Entry(b).State = System.Data.Entity.EntityState.Modified;
 }
 public void MarkAsModified(Product item)
 {
     Entry(item).State = EntityState.Modified;
 }