예제 #1
0
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))
예제 #2
0
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'))
예제 #3
0
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'))
예제 #4
0
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'))
예제 #5
0
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'))
예제 #6
0
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'))
예제 #7
0
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)))