course controller added
This commit is contained in:
parent
042cb14175
commit
c661a70a4a
115
Apollo/api/application/controllers/Course_Controller.php
Normal file
115
Apollo/api/application/controllers/Course_Controller.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: karthi
|
||||
* Date: 11/23/17
|
||||
* Time: 4:11 PM
|
||||
*/
|
||||
class Course_Controller extends REST_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
// Construct the parent class
|
||||
parent::__construct();
|
||||
|
||||
// Configure limits on our controller methods
|
||||
// Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
|
||||
$this->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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user