def create_item(self, type_id, spoil_quick, type_name): results = [] for row in self.items: if len(row) != 0: if row['type_id'] == type_id: results.append(row['type_id']) if results: raise mvc_exc.ItemAlreadyStored( '"{}" already stored!'.format(type_id)) else: results = Type().generator(list([type_id, spoil_quick, type_name])) self.items.append(results) self.db.execute_query( f"INSERT INTO {self.table_name} " f" (type_id, spoil_quick, type_name) " f"VALUES ({results['type_id']}, {results['spoil_quick']}, " f"'{(results['type_name'])}');")
def create_item(self, departament_id, name, country): results = [] for row in self.items: if len(row) != 0: if row['departament_id'] == departament_id: results.append(row['departament_id']) if results: raise mvc_exc.ItemAlreadyStored( '"{}" already stored!'.format(name)) else: results = Departament().generator( list([departament_id, name, country])) self.items.append(results) self.db.execute_query( f"INSERT INTO {self.table_name} " f" (departament_id, name, country) " f"VALUES ({results['departament_id']}, '{results['name']}', " f"'{(results['country'])}');")
def create_item(self, order_id, quantity, date, person_id): results = [] for row in self.items: if len(row) != 0: if row['order_id'] == order_id: results.append(row['order_id']) if results: raise mvc_exc.ItemAlreadyStored( '"{}" already stored!'.format(order_id)) else: results = Order().generator( list([order_id, quantity, date, person_id])) self.items.append(results) self.db.execute_query( f"INSERT INTO {self.table_name} " f" (order_id, quantity, date, person_id) " f"VALUES ({results['order_id']}, {results['quantity']}, " f"'{(results['date'])}', {results['person_id']});")
def create_item(self, person_id, name, address, contact_email, contact_tel_num): results = [] for row in self.items: if len(row) != 0: if row['person_id'] == person_id: results.append(row['person_id']) if results: raise mvc_exc.ItemAlreadyStored( '"{}" already stored!'.format(person_id)) else: results = Person().generator( list( [person_id, name, address, contact_email, contact_tel_num])) self.items.append(results) self.db.execute_query( f"INSERT INTO {self.table_name} " f" (person_id, name, address, contact_email, contact_tel_num) " f"VALUES ({results['person_id']}, '{results['name']}', " f"'{(results['address'])}', '{results['contact_email']}'," f"'{results['contact_tel_num']}');")
def create_item(self, thing_id, quantity, expiration_date, breakable, type_id, order_id, name): results = [] for row in self.items: if len(row) != 0: if row['thing_id'] == thing_id: results.append(row['thing_id']) if results: raise mvc_exc.ItemAlreadyStored( '"{}" already stored!'.format(name)) else: results = Thing().generator( list([ thing_id, quantity, expiration_date, breakable, type_id, order_id, name ])) self.items.append(results) self.db.execute_query( f"INSERT INTO {self.table_name} " f" (thing_id, quantity, expiration_date, breakable, type_id, order_id, name) " f"VALUES ({results['thing_id']}, {results['quantity']}, " f"'{(results['expiration_date'])}', {results['breakable']}, " f"{results['type_id']}, {results['order_id']}, " f"'{results['name']}');")