From c661a70a4a60b64fc59e47073a113dc3128a7251 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Thu, 23 Nov 2017 19:14:00 +0530 Subject: [PATCH] course controller added --- .../controllers/Course_Controller.php | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Apollo/api/application/controllers/Course_Controller.php diff --git a/Apollo/api/application/controllers/Course_Controller.php b/Apollo/api/application/controllers/Course_Controller.php new file mode 100644 index 00000000..070dcb6b --- /dev/null +++ b/Apollo/api/application/controllers/Course_Controller.php @@ -0,0 +1,115 @@ +methods['addCourseDetails_get']['limit'] = 500; // 500 requests per hour per user/key + $this->methods['addCourseDetails_post']['limit'] = 100; // 100 requests per hour per user/key + $this->methods['addCourseDetails_delete']['limit'] = 50; // 50 requests per hour per user/key + $this->methods['getCourseDetails_post']['limit'] = 500; // 50 requests per hour per user/key + $this->methods['updateCourseDetails_post']['limit'] = 500; + // load the model + $this->load->model('Course_model', 'course_model'); + + } + + /* + * This method used to add Course details + * created by kms + * */ + + public function addCourseDetails_post() + { + + $details['CourseID'] = $this->post('courseID'); + $details['CourseName'] = $this->post('courseName'); + $details['UniversityID'] = $this->post('universityName'); + $details['CreatedBy'] = $this->post('createdBy'); + $details['IsActive'] = $this->post('status'); + $courseDetails = $this->course_model->addCourse($details);// Check if the users data store contains users (in case the database result returns NULL) + if ($courseDetails) + { + $courseDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($courseDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'Something went wrong.please try again!', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + + } + /* + * get course details + * created by kms + * */ + public function getCourseDetails_post() + { + $requestedBy = $this->post('requestedBy'); + $getCourse = $this->course_model->getCourse($requestedBy); + + if ($getCourse) + { + $getCourse['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($getCourse, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No records found!', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + + } + /* + * update the course details + * created by kms + * */ + public function updateCourseDetails_post() + { + $details['CourseID'] = $this->post('courseCode'); + $details['CourseName'] = $this->post('courseName'); + $details['IsActive'] = $this->post('status'); + $details['UpdatedBy'] = $this->post('updatedBy'); + $details['UpdatedOn'] = date("Y-m-d", time()); + $updateDetails = $this->course_model->updateCourse($details);// Check if the users data store contains users (in case the database result returns NULL) + if ($updateDetails) + { + $updateDetails['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($updateDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'Something went wrong.please try again!', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } + + + } + + +} \ No newline at end of file