Built motion from commit 5e31ea4.|0.0.32
[motion.git] / server / api / business_condition / business_condition.controller.js
index be8bf04..d480f8e 100644 (file)
@@ -1 +1,93 @@
-var _0xe060=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x42\x75\x73\x69\x6E\x65\x73\x73\x43\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x66\x69\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79"];_0xe060[0];var _=require(_0xe060[1]);var BusinessCondition=require(_0xe060[3])[_0xe060[2]];exports[_0xe060[4]]=function(_0x7eaax3,_0x7eaax4){BusinessCondition[_0xe060[9]]()[_0xe060[8]](function(_0x7eaax6){return _0x7eaax4[_0xe060[7]](200)[_0xe060[6]](_0x7eaax6)})[_0xe060[5]](function(_0x7eaax5){return handleError(_0x7eaax4,_0x7eaax5)})};exports[_0xe060[10]]=function(_0x7eaax3,_0x7eaax4){BusinessCondition[_0xe060[14]](_0x7eaax3[_0xe060[13]][_0xe060[12]])[_0xe060[8]](function(_0x7eaax7){if(!_0x7eaax7){return _0x7eaax4[_0xe060[11]](404)};return _0x7eaax4[_0xe060[6]](_0x7eaax7);})[_0xe060[5]](function(_0x7eaax5){return handleError(_0x7eaax4,_0x7eaax5)})};exports[_0xe060[15]]=function(_0x7eaax3,_0x7eaax4){BusinessCondition[_0xe060[15]](_0x7eaax3[_0xe060[16]])[_0xe060[8]](function(_0x7eaax7){return _0x7eaax4[_0xe060[7]](201)[_0xe060[6]](_0x7eaax7)})[_0xe060[5]](function(_0x7eaax5){return handleError(_0x7eaax4,_0x7eaax5)})};exports[_0xe060[17]]=function(_0x7eaax3,_0x7eaax4){if(_0x7eaax3[_0xe060[16]][_0xe060[12]]){delete _0x7eaax3[_0xe060[16]][_0xe060[12]]};BusinessCondition[_0xe060[20]]({where:{id:_0x7eaax3[_0xe060[13]][_0xe060[12]]}})[_0xe060[8]](function(_0x7eaax7){if(!_0x7eaax7){return _0x7eaax4[_0xe060[11]](404)};var _0x7eaax8=_[_0xe060[18]](_0x7eaax7,_0x7eaax3[_0xe060[16]]);_0x7eaax8[_0xe060[19]]()[_0xe060[8]](function(){return _0x7eaax4[_0xe060[7]](200)[_0xe060[6]](_0x7eaax7)})[_0xe060[5]](function(_0x7eaax5){return handleError(_0x7eaax4,_0x7eaax5)});})[_0xe060[5]](function(_0x7eaax5){return handleError(_0x7eaax4,_0x7eaax5)});};exports[_0xe060[21]]=function(_0x7eaax3,_0x7eaax4){BusinessCondition[_0xe060[20]]({where:{id:_0x7eaax3[_0xe060[13]][_0xe060[12]]}})[_0xe060[8]](function(_0x7eaax7){if(!_0x7eaax7){return _0x7eaax4[_0xe060[11]](404)};_0x7eaax7[_0xe060[21]]()[_0xe060[8]](function(){return _0x7eaax4[_0xe060[11]](204)})[_0xe060[5]](function(_0x7eaax5){return handleError(_0x7eaax4,_0x7eaax5)});})[_0xe060[5]](function(_0x7eaax5){return handleError(_0x7eaax4,_0x7eaax5)})};function handleError(_0x7eaax4,_0x7eaax5){return _0x7eaax4[_0xe060[7]](500)[_0xe060[6]](_0x7eaax5)}
\ No newline at end of file
+'use strict';
+
+var _ = require('lodash');
+var BusinessCondition = require('../../models').BusinessCondition;
+
+// Get list of business_conditions
+exports.index = function(req, res) {
+  BusinessCondition
+  .findAll()
+  .then(function (business_conditions) {
+    return res.status(200).send(business_conditions);
+  })
+  .catch(function(err) {
+    return handleError(res, err);
+  });
+};
+
+// Get a single business_condition
+exports.show = function(req, res) {
+  BusinessCondition
+  .findById(req.params.id)
+  .then(function (business_condition) {
+    if(!business_condition) { return res.sendStatus(404); }
+    return res.send(business_condition);
+  })
+  .catch(function(err){
+    return handleError(res, err);
+  });
+};
+
+// Creates a new business_condition in the DB.
+exports.create = function(req, res) {
+  BusinessCondition
+  .create(req.body)
+  .then(function(business_condition) {
+    return res.status(201).send(business_condition);
+  })
+  .catch(function(err) {
+    return handleError(res, err);
+  });
+};
+
+// Updates an existing business_condition in the DB.
+exports.update = function(req, res) {
+  if(req.body.id) { delete req.body.id; }
+  BusinessCondition
+  .find({
+    where: {
+      id: req.params.id
+    }
+  })
+  .then(function (business_condition) {
+    if(!business_condition) { return res.sendStatus(404); }
+    var updated = _.merge(business_condition, req.body);
+    updated.save()
+    .then(function () {
+      return res.status(200).send(business_condition);
+    })
+    .catch(function(err) {
+      return handleError(res, err);
+    });
+  })
+  .catch(function(err) {
+    return handleError(res, err);
+  });
+};
+
+// Deletes a business_condition from the DB.
+exports.destroy = function(req, res) {
+  BusinessCondition
+  .find({
+    where: {
+      id: req.params.id
+    }
+  })
+  .then(function (business_condition) {
+    if(!business_condition) { return res.sendStatus(404); }
+    business_condition.destroy()
+    .then(function() {
+      return res.sendStatus(204);
+    })
+    .catch(function(err) {
+      return handleError(res, err);
+    });
+  })
+  .catch(function(err) {
+    return handleError(res, err);
+  });
+};
+
+function handleError(res, err) {
+  return res.status(500).send(err);
+}