protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e) { // Read in the ProductID from the DataKeys collection int productID = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex]); // Delete the data ProductsBLL productsAPI = new ProductsBLL(); productsAPI.DeleteProduct(productID); // Rebind the data to the DataList DataList1.DataBind(); }
public IActionResult DeleteProduct(int id) { var product = _productsBLL.GetProductById(id); if (product == null) { return(NotFound()); } _productsBLL.DeleteProduct(product); return(Ok()); }
public void Delete(Guid id) { ProductsBLL pb = new ProductsBLL(); if (!pb.DeleteProduct(id)) { StatusCode(HttpStatusCode.NotFound); } else { StatusCode(HttpStatusCode.OK); } }
public async Task <IHttpActionResult> DeleteProduct(int id) { using (ProductsBLL bll = new ProductsBLL()) { if (bll.ProductExists(id)) { await bll.DeleteProduct(id); } else { return(NotFound()); } } return(Ok()); }
// DELETE: api/Products/5 public bool Delete(int id) => ProductsBLL.DeleteProduct(id);