def deleteItemCategory(id): with SessionManager(Session) as session: try: cat_item = session.query(ItemCategory).filter( ItemCategory.id == id).one() session.delete(cat_item) session.commit() except: return jsonify(error_envelop(404, 'ValueError', 'Id Not Found')) #if succesfully deleted return jsonify(delete_envelop(200))
def deleteDineTable(d_id): with SessionManager(Session) as session: try: sql_dinetable = session.query(DineTable).filter(DineTable.id == d_id).one() session.delete(sql_dinetable) session.commit() return jsonify(delete_envelop(200)) except NoResultFound: #causes when there is no requested id in the database return jsonify(error_envelop(404, 'NoResultFound', 'Id : {0} Not Found'.format(d_id))) #if no except is caught return jsonify(error_envelop(100, 'UnknownError', 'UnknownError Found'))
def deleteEmployeePosition(p_id): with SessionManager(Session) as session: try: sql_position = session.query(EmployeePosition).filter( EmployeePosition.id == p_id).one() session.delete(sql_position) session.commit() return jsonify(delete_envelop(200)) except NoResultFound: #causes when there is no requested id in the database return jsonify( error_envelop(404, 'NoResultFound', 'Id : {0} Not Found'.format(p_id))) #if no except is caught return jsonify(error_envelop(100, 'UnknownError', 'UnknownError Found'))
def deleteBill(b_id): with SessionManager(Session) as session: try: bill = session.query(Bill).filter(Bill.id == b_id).one() session.delete(bill) session.commit() return jsonify(delete_envelop(code=200)) except NoResultFound: #causes when there is no requested id in the database return jsonify( error_envelop( 404, 'NoResultFound', ' Cannot delete!!Id : {0} Not Found'.format(b_id))) return jsonify(error_envelop(400, 'UnknownError', 'Somethig went wrong'))
def deleteEmployeeByPosition(p_id, e_id): with SessionManager(Session) as session: try: sql_employee = session.query(Employee).filter( Employee.id == e_id).one() session.delete(sql_employee) session.commit() return jsonify(delete_envelop(200)) except NoResultFound: #causes when there is no requested id in the database return jsonify( error_envelop( 404, 'NoResultFound', ' Cannot delete!!Id : {0} Not Found'.format(e_id))) except: return jsonify( error_envelop(400, 'UnknownError', 'Somethig went wrong'))
def deleteCustomerByMembership(m_id, c_id): with SessionManager(Session) as session: try: sql_customer = session.query(Customer).filter( Customer.id == c_id).one() session.delete(sql_customer) session.commit() return jsonify(delete_envelop(200)) except NoResultFound: #causes when there is no requested id in the database return jsonify( error_envelop( 404, 'NoResultFound', ' Cannot delete!!Id : {0} Not Found'.format(m_id))) except: return jsonify( error_envelop(400, 'UnknownError', 'Somethig went wrong'))
def deleteCategoryItem(cat_id, item_id): ''' This function will delete the item in the categories Example : DELETE api/v1/itemcategories/12/items/2 HTTP/1.1 Result : { "meta": { "code": 200, "message": "Deleted Successfully" } } ''' with SessionManager(Session) as session: try: sql_item = session.query(Item).filter(Item.id == item_id).one() session.delete(sql_item) session.commit() return jsonify(delete_envelop(code=200)) except: return jsonify( error_envelop( error_code=404, error_type='ValueError', error_message='No ID:{0} found!!'.format(item_id)))