-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployer.Controller.js
More file actions
34 lines (31 loc) · 1.04 KB
/
Employer.Controller.js
File metadata and controls
34 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var request = require('request');
var async = require('async');
var User = require('../models/User');
/**
* @api {get} /user/getEmployerByID Gets Employer by ID
* @apiName Get Employer by ID
* @apiGroup User
*
* @apiParam {String} req.id ID of Employer
*
* @apiSuccess {Employer} Returns Employer Object
*/
exports.getEmployerByID = function (req, res) {
if (req.body) {
if(req.body.id) {
User.findOne({'employer': req.body.id})
.exec(function (err, employer) {
if (err) {
return res.json({success: false, msg: 'Cannot find employer'}).send();
}
if (employer) {
return res.json({success: true, employer: employer}).send();
} else {
return res.json({success: false, msg: 'Cannot find employer'}).send();
}
});
} else {
return res.status(400).json({success: false, msg: 'Check body'}).send();
}
}
}