def get_all_Employees(): c = Employees(connection_data) result = c.get_all_Employees() return jsonify({'data': result})
def get_one_employee(id): employees = EmployeesEntity(EmployeeID=id) c = Employees(connection_data) result = c.get_one_Employees(employees) return jsonify({'data': result})
def add_employees(): data = request.json employees = EmployeesEntity(lastname =data['lastname'], firstname=data['firstname'], birthdate=data['birthdate'], photo=data['photo'], notes=data['notes']) c = Employees(connection_data) message = c.insert(employees) if message is None: return jsonify({ 'message': 'Cannot insert data' }), 500 return jsonify({ 'message': message })
def add_Employees(): data = request.json emp = EmployeesEntity(LastName=data['LastName'], FirstName=data['FirstName'], BirthDate=data['BirthDate'], Photo=data['Photo'], Notes=data['Notes']) c = Employees(connection_data) message = c.insert_Employees(emp) if message is None: return jsonify({'message': 'Cannot insert data'}), 500 return jsonify({'message': message})
def delete_employee_by_id(id): if request.method == 'DELETE': # Delete user by id emp = EmployeesEntity(EmployeeID=id) c = Employees(connection_data) result = c.delete_Employees(emp) return jsonify({'message': result[0]}), result[1] else: # Update user by id data = request.json emp = EmployeesEntity(EmployeeID=id, LastName=data['LastName'], FirstName=data['FirstName'], BirthDate=data['BirthDate'], Photo=data['Photo'], Notes=data['Notes']) c = Employees(connection_data) result = c.update_Employees(emp) return jsonify({'message': result[0]}), result[1]
def delete_employees_by_id(id): if request.method == 'DELETE': # Delete user by id employees = EmployeesEntity(employee_id=id) c = Employees(connection_data) result = c.delete(employees) return jsonify({ 'message': result[0] }), result[1] else: # Update user by id data = request.json employees = EmployeesEntity(employee_id=id, lastname =data['lastname'], firstname=data['firstname'], birthdate=data['birthdate'], photo=data['photo'], notes=data['notes']) c = Employees(connection_data) result = c.update(employees) return jsonify({ 'message': result[0] }), result[1]