'use strict';

/**
Router reference 
router.METHOD(path, callback [, callback ...])
*/ 

//Include express engine
var express =require('express');
//Create the router for this controller file
var router = express.Router();
module.exports = router;

//Model Defining
var mongoose = require('mongoose');
var Appointment = mongoose.model('Appointment');



//Get Request on the root of this controller
router.get('/', function(req,res){
	//Callback function on get finished
	//Render index.ejs
	res.render('appointment/index');
});
router.get('/create', function(req,res){
	//Callback function on get finished
	//Render Appointment Creation View
	res.render('appointment/createAppointment');
});

router.get('/patientView', function(req,res){
	//Callback function on get finished
	//Render Appointment Creation View
	res.render('appointment/patientViewAppointment');
});


//POST Function To Create New Entry
router.post('/insert',function(req,res,next){
	//Since Everything in appointment are packed in req.body
	var appointment = new Appointment(req.body);
	//Save Things in to Database via mongoose api
	Appointment.save(function(err, appointment) {
		//onError do nothing and return error msg 
		if(err){
			return next(err);
		}
		//onSuccess Return itself in json packed formatted
		res.json(appointment);
	});

});

//GET Function to fetch All list  
router.get('/getAll',function(req,res,next) {
	//Populate Everything
	Appointment.find(function(err,appointment){
		if(err){
			return next(err);
		}
	
	});


});
@@ -10,17 +10,16 @@
 ct';%0A%0A/*
-*
 %0ARouter 
@@ -348,54 +348,529 @@
 );%0A%0A
-%0A%0A//Get Request on the root of this controller
+////////////////////////////////////////////%0A//Class Required%0A////////////////////////////////////////////%0Avar UserControl = require('../controllers/UserControl.js');%0Avar RoundWardControl = require('../controllers/RoundWardControl.js');%0Avar NotificationControl = require('../controllers/NotificationControl.js');%0Avar AppointmentControl = require('../controllers/AppointmentControl.js');%0A%0A%0A////////////////////////////////////////////%0A//PAGE REQUEST under URL = '/appointment'%0A////////////////////////////////////////////%0A
 %0Arou
@@ -892,32 +892,48 @@
 nction(req,res)%7B
+ //Default Route
 %0A%09//Callback fun
@@ -1353,16 +1353,137 @@
 ;%0A%7D);%0A%0A%0A
+%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A////////////////////////////////////////////%0A%0A// 
 //POST F
@@ -1510,16 +1510,19 @@
 w Entry%0A
+// 
 router.p
@@ -1559,16 +1559,19 @@
 ,next)%7B%0A
+// 
 %09//Since
@@ -1620,16 +1620,19 @@
 eq.body%0A
+// 
 %09var app
@@ -1669,16 +1669,19 @@
 .body);%0A
+// 
 %09//Save 
@@ -1719,16 +1719,19 @@
 ose api%0A
+// 
 %09Appoint
@@ -1769,16 +1769,19 @@
 ment) %7B%0A
+// 
 %09%09//onEr
@@ -1817,16 +1817,19 @@
 or msg %0A
+// 
 %09%09if(err
@@ -1823,32 +1823,35 @@
  %0A// %09%09if(err)%7B%0A
+// 
 %09%09%09return next(e
@@ -1855,20 +1855,26 @@
 t(err);%0A
+// 
 %09%09%7D%0A
+// 
 %09%09//onSu
@@ -1918,16 +1918,19 @@
 rmatted%0A
+// 
 %09%09res.js
@@ -1950,19 +1950,28 @@
 t);%0A
+// 
 %09%7D);%0A%0A
+// 
 %7D);%0A%0A
+// 
 //GE
@@ -2001,16 +2001,19 @@
  list  %0A
+// 
 router.g
@@ -2050,16 +2050,19 @@
 next) %7B%0A
+// 
 %09//Popul
@@ -2076,16 +2076,19 @@
 rything%0A
+// 
 %09Appoint
@@ -2124,16 +2124,19 @@
 tment)%7B%0A
+// 
 %09%09if(err
@@ -2138,16 +2138,19 @@
 f(err)%7B%0A
+// 
 %09%09%09retur
@@ -2166,20 +2166,29 @@
 r);%0A
+// 
 %09%09%7D%0A%09%0A
+// 
 %09%7D);%0A%0A%0A
+// 
 %7D);

Add Class Routing to Ctrl-Appointment.js