Ejemplo n.º 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();
    }
Ejemplo n.º 2
0
        public IActionResult DeleteProduct(int id)
        {
            var product = _productsBLL.GetProductById(id);

            if (product == null)
            {
                return(NotFound());
            }

            _productsBLL.DeleteProduct(product);

            return(Ok());
        }
Ejemplo n.º 3
0
        public void Delete(Guid id)
        {
            ProductsBLL pb = new ProductsBLL();

            if (!pb.DeleteProduct(id))
            {
                StatusCode(HttpStatusCode.NotFound);
            }
            else
            {
                StatusCode(HttpStatusCode.OK);
            }
        }
Ejemplo n.º 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();
    }
Ejemplo n.º 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());
        }
Ejemplo n.º 6
0
 // DELETE: api/Products/5
 public bool Delete(int id) => ProductsBLL.DeleteProduct(id);