var mongoose = require('mongoose');
var Class = mongoose.model('Class');

var sendJSONresponse = function(res, status, content) {
  res.status(status);
  res.json(content);
};

module.exports.classesGetAll = function(req, res) {
    sendJSONresponse(res, 200, {"status": "success"});
};

module.exports.professorsForClass = function(req, res) {
    sendJSONresponse(res, 200, {"status": "success"});
};
@@ -65,16 +65,56 @@
 Class');
+%0Avar Prof = mongoose.model('Professor');
 %0A%0Avar se
@@ -214,229 +214,1319 @@
 %7D;%0A%0A
-module.exports.classesGetAll = function(req, res) %7B%0A    sendJSONresponse(res, 200, %7B%22status%22: %22success%22%7D);%0A%7D;%0A%0Amodule.exports.professorsForClass = function(req, res) %7B%0A    sendJSONresponse(res, 200, %7B%22status%22: %22success
+var errNotFound = %7B%22message%22: %22Not found%22%7D;%0A%0Avar success = function(res, data) %7B%0A    sendJSONresponse(res, 200, data);%0A%7D%0A%0Avar errorGet = function(res, err) %7B%0A    sendJSONresponse(res, 404, err); // 404 is standard code for GET error%0A%7D;%0A%0Amodule.exports.classesGetAll = function(req, res) %7B%0A    Class%0A        .find()%0A        .exec(function(err, classes)%7B%0A            // error handling first%0A            if (!classes) %7B%0A                errorGet(res, errNotFound);%0A                return;%0A            %7D else if (err) %7B%0A                errorGet(res, err);%0A                return;%0A            %7D%0A            %0A            %0A            // otherwise, success%0A            success(res, classes);%0A        %7D);%0A%7D;%0A%0Amodule.exports.professorsForClass = function(req, res) %7B%0A    if (req.params && req.params.classid) %7B%0A        Class%0A            .findById(req.params.classid)%0A            .exec(function(err, dbclass)%7B%0A                if (!dbclass %7C%7C !dbclass.professors) %7B%0A                    errorGet(res, errNotFound);%0A                    return;%0A                %7D else if (err) %7B%0A                    errorGet(res, err);%0A                    return;%0A                %7D%0A                %0A                success(res, dbclass.professors);%0A            %7D);%0A    %7D else %7B%0A        errorGet(res, %7B%22message%22: %22No classid in request
 %22%7D);%0A
+    %7D%0A
 %7D;

Return MongoDB data for class and professor requests.