Feat/controllers - refactor entire backend and new admin interface #75

Merged
KevinMidboe merged 117 commits from feat/controllers into master 2021-02-19 00:19:52 +00:00
Showing only changes of commit c98ccbc3f0 - Show all commits

View File

@@ -1,7 +1,7 @@
const path = require("path");
const Winner = require(path.join(__dirname, "/schemas/Highscore"));
const Wine = require(path.join(__dirname, "/schemas/Wine"));
const WineRepository = require(path.join(__dirname, "/wine"));
class HistoryByDateNotFound extends Error {
constructor(message = "History for given date not found.") {
@@ -24,10 +24,15 @@ const addWinnerWithWine = async (winner, wine) => {
const exisitingWinner = await Winner.findOne({
name: winner.name
});
const savedWine = await WineRepository.addWine(wine);
const date = new Date();
date.setHours(5, 0, 0, 0);
const winObject = { date, wine, color: winner.color };
const winObject = {
date: date,
wine: savedWine,
color: winner.color
};
if (exisitingWinner == undefined) {
const newWinner = new Winner({