title: deleting a product by id in webapi
body: <p>I am working on a WebAPI.</p>
  
  <p>I would like to delete a product by the id. 
  However, with my code, it deleted all the records.
  When I key in the id number, instead of deleting the id itself, it deleted the whole records.
  May I know what is wrong with my code?
  how can I improve it to delete it by id.</p>
  
  <p>productcontroller.cs</p>
  
  <pre><code>  function ProductViewModel(product) {
                  var self = this;
  
                  self.Id = product.Id;
                  self.Name = product.Name;
                  self.Price = product.Price;
                  self.Category = product.Category;
              }
  
              self.products = ko.observableArray();   // Contains the list of products
              self.product = ko.observable();
  
              self.status = ko.observable();
  
  
  public void DeleteProduct(int id)
  {
       Product item = repository.Get(id);
       if (item == null)
       {
            throw new HttpResponseException(HttpStatusCode.NotFound);
       }
       repository.Remove(id);    
  }
  </code></pre>
  
  <p>.cshtml</p>
  
  <pre><code> // Get delete product
  
  
   self.remove = function () {
  
      self.products.remove();
      $.getJSON("/api/products", function (products) {
          $.each(products, function (index, product) {
              self.products.pop(new ProductViewModel(product));
          })
      });
  }
  </code></pre>
  
  <p>productrespository.cs</p>
  
  <pre><code>public void Remove(int id)
          {
              products.RemoveAll(p =&gt; p.Id == id);
          }
  </code></pre>