public bool DeleteProduct(Products product)
        {
            ProductsDAO dao   = new ProductsDAO();
            bool        error = false;

            if (product != null)
            {
                if (dao.CountProductOrder(product) > 0)
                {
                    error = true;
                }
                if (dao.CountProductSales(product) > 0)
                {
                    error = true;
                }

                if (!error)
                {
                    dao.DeleteProduct(product);
                }
                else
                {
                    dao.ChangeProductActivated(product, false);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
    public void DeleteProduct(int id)
    {
        ProductsDAO dao           = new ProductsDAO();
        Product     deleteProduct = dao.GetProduct(id);

        if (deleteProduct != null)
        {
            int result = dao.DeleteProduct(deleteProduct);
            if (result < 1)
            {
                throw new Exception("No es posible eliminar el Producto");
            }
        }
        else
        {
            throw new Exception("El id del Producto a eliminar no es válido");
        }
    }
Exemplo n.º 3
0
 public bool DeleteProduct(int id, out string serverMessage) => _productsContext.DeleteProduct(id, out serverMessage);