def update_category_by_id(category_id): data = request.json category = bo.Category(CategoryID=category_id, CategoryName=data['CategoryName'], Description=data['Description']) result = do.Category(ConnectionData).update(category) return jsonify({'message': result[0]}), result[1]
def delete_category_by_id(category_id): c = bo.Category(CategoryID=category_id) result = do.Category(ConnectionData).delete(c) return jsonify({'message': result[0]}), result[1]
def insert_category(): data = request.json category = bo.Category(1, data['CategoryName'], data['Description']) result = do.Category(ConnectionData).insert(category) return jsonify({'message': result}), 200
def get_category_by_id(category_id): category = bo.Category(CategoryID=category_id) result = do.Category(ConnectionData).get_by_id(category) if result[1] != 200: return jsonify({'message': result[0]}), result[1] return jsonify(result[0].to_json()), 200
def get_all_category(): c = do.Category(ConnectionData).get_all() return jsonify(c), 200