This commit is contained in:
@ -4,7 +4,7 @@ from models.products.product import Product
|
||||
|
||||
class ProductController(DatabaseController):
|
||||
FIELDS = ['id', 'name', 'image', 'description', 'cost',
|
||||
'category', 'sellerID', 'postedDate', 'quantityAvailable']
|
||||
'sellerID', 'category', 'postedDate', 'quantityAvailable']
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@ -131,8 +131,30 @@ class ProductController(DatabaseController):
|
||||
|
||||
return products
|
||||
|
||||
def update(self):
|
||||
print("Doing work")
|
||||
def update(self, product: Product):
|
||||
params = [
|
||||
product.name,
|
||||
product.description,
|
||||
product.image,
|
||||
product.cost,
|
||||
product.quantityAvailable,
|
||||
product.category,
|
||||
product.id
|
||||
]
|
||||
|
||||
cursor = self._conn.execute(
|
||||
"""UPDATE Products
|
||||
SET name = ?,
|
||||
description = ?,
|
||||
image = ?,
|
||||
cost = ?,
|
||||
quantityAvailable = ?,
|
||||
categoryID = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
params
|
||||
)
|
||||
self._conn.commit()
|
||||
|
||||
def delete(self):
|
||||
print("Doing work")
|
||||
|
Reference in New Issue
Block a user