def del_employees(empid):
     try:
         EmployeeService.delete_employee(int(empid))
         return f'Employee with id of  {empid} has been deleted', 204
     except ValueError as e:
         return "Not a valid ID or No such user exist with this ID", 400  # Bad Request
     except ResourceNotFound as r:
         return r.message, 404
 def put_employees(empid):
     try:
         emp = Employee.json_parse(request.json)
         emp.empid = int(empid)
         EmployeeService.update_employee(emp)
         return jsonify(emp.json()), 200
     except ValueError as e:
         return "Not a valid ID or No such user exist with this ID", 400  # Bad Request
     except ResourceNotFound as r:
         return r.message, 404
    def get_employee(empid):
        try:
            emp = EmployeeService.get_employee(int(empid))

            return jsonify(emp.json()), 200
        except ValueError as e:
            return "Not a valid ID or No such user exist with this ID", 400  # Bad Request
        except ResourceNotFound as r:
            return r.message, 404
Exemple #4
0
 def get_employee_courses(empid):
     try:
         if EmployeeService.get_employee(int(empid)):
             course = CourseService.get_courses(empid)
             return jsonify(course), 200
     except ValueError as e:
         return "Not a valid ID or No such user exist with this ID", 400  # Bad Request
     except ResourceNotFound as r:
         return r.message, 404
 def post_tuition(empid):
     # try:
     reimburse = Tuition.json_parse(request.json)
     emp = EmployeeService.get_employee(empid)
     if emp:
         print(emp)
         reimburse_serv = TuitionService.create_tuition(reimburse, empid)
         return jsonify(str(reimburse_serv)), 201
     else:
         return f"Employee ID {empid} not Found", 404
 def update_tuition(empid):
     try:
         new_empid = EmployeeService.get_employee(int(empid))
         if new_empid:
             reimburse = Tuition.json_parse(request.json)
             tuition = TuitionService.update_tuition(reimburse, empid)
             return jsonify(str(tuition)), 200
     except ValueError as e:
         return "Not a valid ID or No such user exist with this ID", 400  # Bad Request
     except ResourceNotFound as r:
         return r.message, 404
 def get_Employee_tuition(empid):
     try:
         new_empid = EmployeeService.get_employee(int(empid))
         if new_empid:
             new_tuitions = TuitionService.get_tuition_id(empid)
             print("printing ", empid)
             return jsonify(new_tuitions.json()), 200
     except ValueError as e:
         return "Not a valid ID or No such user exist with this ID", 400  # Bad Request
     except ResourceNotFound as r:
         return r.message, 404
 def rejected_process(cls, empid):  # rejecting a reimbursement
     emp = EmployeeService.get_employee(
         int(empid))  # Get the specific employee to be approved/rejected
     if emp:
         get_tuit = TuitionService.get_tuition_id(
             empid)  # get get/view the reimbursement form information
         get_tuit.submision_status = "Rejected"
         tuition_approve = TuitionService.update_tuition_reject(
             get_tuit, empid)
         return jsonify(str(tuition_approve)), 200
     else:
         return "Employee not found", 404
 def approval_process(cls, empid):
     emp = EmployeeService.get_employee(
         empid)  # Get the specific employee to be approved/rejected
     if emp:
         get_tuit = TuitionService.get_tuition_id(
             empid)  # get get/view the reimbursement form information
         print("geting stuff", get_tuit)
         get_tuit.submision_status = "Approved"
         tuition_approve = TuitionService.update_tuition(get_tuit, empid)
         return jsonify(str(tuition_approve)), 200
     else:
         return "Employee not found", 404
Exemple #10
0
    def update_course(empid, courseid):
        # try:
        emp = EmployeeService.get_employee(int(empid))
        if emp:
            # print(emp)
            get_course = CourseService.get_course_ID(int(courseid))

            if get_course:
                all_course = Courses.json_parse(request.json)
                CourseService.update_course(all_course, courseid)
                return jsonify(all_course.json()), 200
            else:
                return f'Course ID {courseid} - not found', 404
        else:
            return f'Employee ID {emp} - not found', 404
 def get_all_employee():
     return jsonify(EmployeeService.all_employee()), 200
 def post_employees():
     emp = Employee.json_parse(request.json)
     empserv = EmployeeService.create_employee(emp)
     return jsonify(empserv.json()), 201  # resource created