def find_by(self, _id): customers = self.find_all() if customers: customer = Common.filter_result('customer_id', _id, customers) return next(customer, None) return None
def find_by_email(self, _email): customers = self.find_all() if customers: customer = Common.filter_result('email', _email, customers) return next(customer, None) return None
def find_by_customer(self, customer_id): carts = self.find_all() customer = Common.filter_result('customer_id', customer_id, carts) return next(customer, None)
def find_by_item(self, item_id, cart): item = Common.filter_result('item_id', item_id, cart["items"]) return next(item, None)
def find_by(self, _id): orders = self.find_all() order = Common.filter_result('order_id', _id, orders) return next(order, None)
def search_by(self, customer_id, order_id): customer_orders = self.find_by_customer(customer_id) order = Common.filter_result('order_id', order_id, customer_orders) return next(order, None)
def find_by_customer(self, _id): orders = self.find_all() customer_orders = Common.filter_result('customer_id', _id, orders) return list(customer_orders)
def find_by_name(self, products, _name): product_name = _name.replace('_', ' ') product = Common.filter_result('name', product_name, products) return next(product, None)
def find_by(self, products, _id): product = Common.filter_result('product_id', _id, products) return next(product, None)