Created
May 5, 2014 08:03
-
-
Save shadowzick/f56985e77cb7a2deb454 to your computer and use it in GitHub Desktop.
employee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.new = function(req, res) { | |
var api = require('../lib/api')(req.session); | |
var template = require('../lib/template')(res.locals); | |
template.setTitle("New Equipment"); | |
var templateData = {}; | |
var renderView = function() { | |
res.render('partials/equipment/new', templateData); | |
}; | |
if(req.method === 'POST') { | |
var data = { | |
type: req.body.type, | |
make: req.body.make, | |
model: req.body.model, | |
serial_number: req.body.serial_number, | |
purchase_price: req.body.purchase_price, | |
purchase_date: req.body.purchase_date, | |
purchase_location: req.body.purchase_location | |
}; | |
console.log(data); | |
api.Equipment.create(data, function(err, result) { | |
res.redirect('/equipment'); | |
}); | |
} else { | |
renderView(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment