Exemplo n.º 1
0
 def insertTransaction(self, form):
     if len(form) != 9:
         return jsonify(Error="Malformed post Transaction"), 400
     else:
         s_id = form['s_id']
         b_id = form['b_id']
         ba_id = form['ba_id']
         c_id = form['c_id']
         r_id = form['r_id']
         t_qty = form['t_qty']
         t_total = form['t_total']
         t_donation = form['t_donation']
         t_reservation = form['t_reservation']
         if s_id and b_id and ba_id and c_id and r_id and t_qty and t_total and t_donation and t_reservation:
             dao = TransactionDAO()
             t_id = dao.insert(s_id, b_id, ba_id, c_id, r_id, t_qty,
                               t_total, t_donation, t_reservation)
             result = self.build_transaction_attributes(
                 t_id, s_id, b_id, ba_id, c_id, r_id, t_qty, t_total,
                 t_donation, t_reservation)
             return jsonify(Transaction=result), 201
         else:
             return jsonify(
                 Error="Unexpected attributes in post Transaction"), 400
Exemplo n.º 2
0
 def insertTransaction(self, form):
     if form and len(form) == 6:
         s_id = form['s_id']
         c_id = form['c_id']
         r_id = form['r_id']
         t_price = form['t_price']
         t_date = form['t_date']
         t_qty = form['t_qty']
         if s_id and c_id and r_id and t_price and t_date and t_qty:
             dao = TransactionDAO()
             t_id = dao.insert(s_id, c_id, r_id, t_price, t_date, t_qty)
             result = {}
             result["t_id"] = t_id
             result["s_id"] = s_id
             result["c_id"] = c_id
             result["r_id"] = r_id
             result["t_price"] = t_price
             result["t_date"] = t_date
             result["t_qty"] = t_qty
             return jsonify(Transaction=result), 201
         else:
             return jsonify(Error="Malformed post request")
     else:
         return jsonify(Error="Malformed post request")