def get_by_id(card_id): result = DAO.select( "SELECT * FROM cards WHERE id = {}".format(card_id)) if len(result) == 0: raise FanIDCardNotFoundError( "Fan ID Card {} does not exist".format(card_id)) return result[0]
def get_card_by_username(username): result = DAO.select( "SELECT * FROM cards WHERE username = '******'".format(username)) if len(result) == 0: raise UsernameNotFoundError( "Username {} was not found in the system".format(username)) return result[0]
def does_exist(username): result = DAO.select( "SELECT * FROM person WHERE username = '******'".format(username)) return len(result) > 0
def get_role_by_username(username): result = DAO.select( "SELECT role FROM person WHERE username = '******'".format(username)) return result[0][0]
def is_password_correct(username, password): encrypted_password = PersonDAO.encrypt_password(password) result = DAO.select( "SELECT * FROM person WHERE username = '******' and password = '******'". format(username, encrypted_password)) return len(result) != 0
def get_by_id(username): result = DAO.select( "SELECT * FROM person WHERE username = '******'".format(username)) if len(result) == 0: raise UsernameNotFoundError("Username was not found") return result[0]
def get_available_tickets_id_and_seats_and_price(match_id): return DAO.select( "SELECT id, block, row, place, price FROM tickets WHERE match_id = {} AND card_id is NULL ORDER BY id" .format(match_id))
def get_max_match_id(): max_match_id = DAO.select("SELECT MAX(id) FROM matches")[0][0] return max_match_id
def does_exist(ticket_id): result = DAO.select( "SELECT * FROM tickets WHERE id = {}".format(ticket_id)) return len(result) > 0
def get_tickets_id_by_card_id(card_id): return DAO.select( "SELECT id FROM tickets WHERE card_id = {} ORDER BY id".format( card_id))
def get_by_id(ticket_id): return DAO.select( "SELECT * FROM tickets WHERE id = {}".format(ticket_id))[0]
def does_exist(match_id): result = DAO.select( "SELECT * FROM matches WHERE id = {}".format(match_id)) return len(result) > 0
def get_matches(): return DAO.select("SELECT * FROM matches ORDER BY id")
def does_exist(card_id): result = DAO.select( "SELECT * FROM cards WHERE id = {}".format(card_id)) return len(result) > 0
def get_paid_money(match_id): result = DAO.select( "SELECT card_id, price FROM tickets WHERE match_id = {}".format( match_id)) return result
def get_max_card_id(): max_card_id = DAO.select("SELECT MAX(id) FROM cards")[0][0] return max_card_id
def get_by_id(match_id): return DAO.select( "SELECT * FROM matches WHERE id = {}".format(match_id))[0]