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); }
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"); } }
public bool DeleteProduct(int id, out string serverMessage) => _productsContext.DeleteProduct(id, out serverMessage);