mirror of
https://github.com/QualityInUse/lab-testing-maksktl.git
synced 2026-08-05 16:35:27 +03:00
22 lines
802 B
Python
22 lines
802 B
Python
class Customer:
|
|
def __init__(self, database, customer_id=None, name=None, address=None):
|
|
self.database = database
|
|
self.customer_id = customer_id
|
|
if customer_id is None and name and address:
|
|
self.customer_id = self.database.add_customer(name, address)
|
|
elif customer_id:
|
|
self._load_customer()
|
|
|
|
def _load_customer(self):
|
|
details = self.database.get_customer(self.customer_id)
|
|
if details:
|
|
self.name, self.address = details[1], details[2]
|
|
else:
|
|
raise ValueError("Customer does not exist.")
|
|
|
|
def update_details(self, name, address):
|
|
self.database.update_customer(self.customer_id, name, address)
|
|
|
|
def delete_customer(self):
|
|
self.database.delete_customer(self.customer_id)
|