Beispiel #1
0
    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();
    }
Beispiel #2
0
        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);
            }
        }
Beispiel #4
0
    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();
    }
Beispiel #5
0
        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);