This repository has been archived on 2024-04-05. You can view files and clone it, but cannot push or open issues/pull-requests.
score-tracker/routes/manage.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-11-22 06:17:43 +00:00
var express = require('express');
var router = express.Router();
var genders = require('../database/scores/genders');
var games = require('../database/scores/games');
2021-11-23 01:04:36 +00:00
var seasons = require('../database/scores/seasons');
2021-11-22 06:17:43 +00:00
router.get('/', function(req, res, next) {
res.render('manage', { title: 'Score Management' });
});
router.get('/addgame', function(req, res, next) {
res.render('manage/addgame', { title: 'Submit Score' });
});
router.post('/submitgame', 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 = 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"));
});
2021-11-23 01:04:36 +00:00
router.get('/addseason', function(req, res, next) {
res.render('manage/addseason', { title: 'Add season', currentYear : (new Date()).getFullYear() });
});
router.post('/submitseason', function(req, res, next) {
const year = req.body['year'];
seasons.add(year)
.then(res.send("SUCCESS"));
});
2021-11-22 06:17:43 +00:00
module.exports = router;