public IHttpActionResult Delete(int id) { if (id <= 0) { return(BadRequest("Not a valid student id")); } using (var ctx = new ProductStoreDB()) { var product = ctx.Products .Where(p => p.ProductID == id) .FirstOrDefault(); ctx.Entry(product).State = System.Data.Entity.EntityState.Deleted; ctx.SaveChanges(); } return(Ok()); }