예제 #1
0
class TrolleyRepository:
    def __init__(self):
        self.dao = TrolleyDao()

    def deleteTrolley(self, trolley_id):
        trolley_id = self.dao.deleteTrolley(trolley_id)

        return trolley_id

    def getAllTrolleys(self):
        result = self.dao.getAllTrolleys()
        trolleys = []

        if result:
            for row in result:
                trolley = Trolley(row)
                trolleys.append(trolley)

        return trolleys

    def getTrolleyById(self, trolley_id):
        result = self.dao.getTrolleyById(trolley_id)
        trolley = None

        if result:
            trolley = Trolley(result)

        return trolley
예제 #2
0
def trolleyFactory(plate, capacity, mileage):
    dao = TrolleyDao()

    trolley_id = dao.insert(plate, capacity, mileage)
    data = dao.getTrolleyById(trolley_id)
    trolley = Trolley(data)

    return trolley
예제 #3
0
    def getAllTrolleys(self):
        dao = TrolleyDao()
        results_list = dao.getAllTrolleys()
        trolleys_list = []

        trolleys_list = trolleyRepository(results_list)
        trolleys_list = list(map(getInfo, trolleys_list))

        return jsonify(Trolleys=trolleys_list)
예제 #4
0
    def getTrolleyByPlate(self, plate):
        dao = TrolleyDao()
        result = dao.getTrolleyByPlate(plate)

        if not result:
            return jsonify(Error="Trolley Not Found"), 404
        else:
            trolley = trolleyRepository(result)
            trolley = getInfo(trolley)
            return jsonify(Trolley=trolley)
예제 #5
0
    def factory(self, plate, capacity, mileage):
        dao = TrolleyDao()

        trolley_id = dao.registerTrolley(plate, capacity, mileage)
        data = dao.getTrolleyById(trolley_id)

        self.trolley['trolley_id'] = data['trolley_id']
        self.trolley['plate'] = data['plate']
        self.trolley['capacity'] = data['capacity']
        self.trolley['mileage'] = data['mileage']
예제 #6
0
    def getTrolleysByMileageRange(self, mileage_low, mileage_high):
        dao = TrolleyDao()
        results_list = dao.getTrolleysByMileageRange(mileage_low, mileage_high)
        trolleys_list = []

        if not results_list:
            return jsonify(Error="Trolleys Not Found"), 404
        else:
            trolleys_list = trolleyRepository(results_list)
            trolleys_list = list(map(getInfo, trolleys_list))
            return jsonify(Trolleys=trolleys_list)
예제 #7
0
    def getTrolleysByCapacity(self, capacity):
        dao = TrolleyDao()
        results_list = dao.getTrolleysByCapacity(capacity)
        trolleys_list = []

        if not results_list:
            return jsonify(Error="Trolleys Not Found"), 404
        else:
            trolleys_list = trolleyRepository(results_list)
            trolleys_list = list(map(getInfo, trolleys_list))
            return jsonify(Trolleys=trolleys_list)
예제 #8
0
 def __init__(self):
     self.dao = TrolleyDao()