var express = require('express'); var router = express.Router(); var genders = require('../database/scores/genders'); var games = require('../database/scores/games'); /* GET submit page. */ router.get('/', function(req, res, next) { res.render('submit', { title: 'Submit Score' }); }); /* POST submit page. */ router.post('/', function(req, res, next) { const seasonID = req.body['year']; const sportID = req.body['sport']; const gender = (req.body['gender'] == "female") ? genders.FEMALE : genders.MALE; const divisionID = req.body['division']; const date = moment(req.body['date']); const team1ID = req.body['team1']; const team1Score = req.body['team1-score']; const team2ID = req.body['team2']; const team2Score = req.body['team2-score']; games.add(divisionID, seasonID, date, team1ID, team2ID, team1Score, team2Score) .then(res.send("SUCCESS")); }); module.exports = router;