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);
60 return res.status(200).send(mailServerIn);
62 .catch(function (err) {
64 return handleError(res, err);
67 .catch(function (err) {
69 return handleError(res, err);
73 // Deletes a mailServerIn from the DB.
74 exports.destroy = function (req, res) {
76 .findById(req.params.id)
77 .then(function (mailServerIn) {
79 return res.sendStatus(404);
84 return res.sendStatus(204);
86 .catch(function (err) {
88 return handleError(res, err);
91 .catch(function (err) {
92 return handleError(res, err);
96 function handleError(res, err) {
97 return res.status(500).send(err);