예제 #1
0
 def getCategory(self):
     dao = ProductsDAO()
     category_list = dao.getCategory()
     results_list = []
     for row in category_list:
         result = self.build_category_dict(row)
         results_list.append(result)
     return jsonify(Categories=results_list)
예제 #2
0
 def getAllProduct(self):
     dao = ProductsDAO()
     products_list = dao.getAllProducts()
     results_list = []
     for row in products_list:
         result = self.build_products_dict(row)
         results_list.append(result)
     return jsonify(Products=results_list)
예제 #3
0
 def getAllPurchases(self, form):
     dao = ProductsDAO()
     purchase_list = dao.getAllPurchases()
     results_list = []
     for row in purchase_list:
         result = self.build_purchases_dict(row)
         results_list.append(result)
     return jsonify(Purchases=results_list)
예제 #4
0
 def getProductsByCategory(self, cid):
     dao = ProductsDAO()
     products_list = dao.getProductsByCategory(cid)
     results_list = []
     for row in products_list:
         result = self.build_ProductsCategory_dict()
         results_list.append(result)
     return jsonify(Products=results_list)
예제 #5
0
    def getAllProductsBySeller(self, uid):
        dao = ProductsDAO()
        products_list = dao.getAllProductsBySeller(uid)
        results_list = []
        for row in products_list:
            result = self.build_ProductsSeller_dict(row)
            results_list.append(result)

        return jsonify(Products_By_User=results_list)
예제 #6
0
    def insertCategory(self, form):

        if form and len(form) == 1:

            cat_name = form['cat_name']

            if cat_name:
                dao = ProductsDAO()
                cid = dao.insertCategory(cat_name)
                result = {}
                result['cid'] = cid
                result['cat_name'] = cat_name
                return jsonify(Categories=result)
            else:
                return jsonify(Error="unexpected attributes in post request"), 400
        else:
            return jsonify(Error="Malformed post request"), 400
예제 #7
0
 def makePurchase(self, form):
     if form and len(form) == 3:
         uid = form['uid']
         pid = form['pid']
         p_qty = form['p_qty']
         if uid and pid and p_qty:
             dao = ProductsDAO()
             caid = dao.makePurchase(uid, pid, p_qty)
             result = {}
             result['caid'] = caid
             result['uid'] = uid
             result['pid'] = pid
             result['p_qty'] = p_qty
             return jsonify(Cart_Item=result)
         else:
             return jsonify(Error="unexpected attributes in post request"), 400
     else:
         return jsonify(Error="Malformed post request"), 400