3 var _ = require('lodash');
4 var MailServerIn = require('../../models').MailServerIn;
6 // Get list of mail_server_ins
7 exports.index = function(req, res) {
10 .then(function(mail_server_ins) {
11 return res.status(200).send(mail_server_ins);
13 .catch(function(err) {
14 return handleError(res, err);
18 // Get a single mailServerIn
19 exports.show = function(req, res) {
21 .findById(req.params.id)
22 .then(function(mailServerIn) {
24 return res.sendStatus(404);
26 return res.send(mailServerIn);
28 .catch(function(err) {
29 return handleError(res, err);
33 // Creates a new mailServerIn in the DB.
34 exports.create = function(req, res) {
37 .then(function(mailServerIn) {
38 return res.status(201).send(mailServerIn);
40 .catch(function(err) {
41 return handleError(res, err);
45 // Updates an existing mailServerIn in the DB.
46 exports.update = function(req, res) {
51 .findById(req.params.id)
52 .then(function(mailServerIn) {
54 return res.sendStatus(404);
56 var updated = _.merge(mailServerIn, req.body);
59 return res.status(200).send(mailServerIn);
61 .catch(function(err) {
63 return handleError(res, err);
66 .catch(function(err) {
68 return handleError(res, err);
72 // Deletes a mailServerIn from the DB.
73 exports.destroy = function(req, res) {
75 .findById(req.params.id)
76 .then(function(mailServerIn) {
78 return res.sendStatus(404);
83 return res.sendStatus(204);
85 .catch(function(err) {
87 return handleError(res, err);
90 .catch(function(err) {
91 return handleError(res, err);
95 function handleError(res, err) {
96 return res.status(500).send(err);