def customers(customer_id): """Routes requests to `create_customer()` or `show_customer_accounts()`""" if request.method == 'POST': return customer.create_customer(api_utils.get_data(request)) elif request.method == 'GET' and customer_id: return customer.show_accounts(customer_id) else: return customer.list_customers()
def add_customer(): rooms, found, position = get_and_print_room_by_no() if found: room_no = rooms[position].room_no customers = customerTable.get_records() if len(customers) == 0: customer_id = 0 else: customer_id = customers[len(customers) - 1].customer_id + 1 customer = create_customer(customer_id, room_no) confirm = input("Complete the operation? (Y/N) ") if confirm.lower() == 'y': customerTable.add_record(customer) change_room_status(room_no, False) print("Operation Successful") else: print("Operation Canceled")
def add_customer(database, cursor): room = get_and_print_room_by_no(cursor) if room is not None: customer = create_customer(room.room_no) confirm = input("Complete the operation? (Y/N) ").lower() if confirm == 'y': query = "insert into {0}(name, address, phone, room_no, entry) values('{1}','{2}','{3}',{4},'{5}')". \ format(TABLE_NAME, customer.name, customer.address, customer.phone, customer.room_no, customer.entry_date.strftime("%Y-%m-%d %H:%M:%S")) try: cursor.execute(query) database.commit() except mysql.connector.Error: create_table(database) cursor.execute(query) database.commit() change_room_status(database, cursor, room.room_id, False) print("Operation Successful") else: print("Operation Canceled")
def create_customer(self, req_body): return create_customer(req_body, self.api_key)
def get(self): message = create_customer(self) pub(message) # send the message out! self.write('OK') self.finish()