func (gs GameService) createGame(c *gin.Context) {
	leagueID := getLeagueIDFromURL(c)

	var game domain.Game

	c.Bind(&game)

	game.ID = 0
	game.LeagueID = leagueID

	gs.doSaveGame(game, c)
}
Beispiel #2
0
func (dao *GameDao) SaveGame(game domain.Game) (*domain.Game, error) {
	if game.ID == 0 {
		gameID, _, _ := datastore.AllocateIDs(dao.Context, EntityGame, nil, 1)
		game.ID = gameID
	}

	leagueKey := datastore.NewKey(dao.Context, EntityLeague, "", game.LeagueID, nil)
	game.League = leagueKey
	key := datastore.NewKey(dao.Context, EntityGame, "", game.ID, leagueKey)

	g, err := dao.save(key, &game)

	if err != nil {
		return nil, err
	}

	savedGame := g.(*domain.Game)

	return savedGame, err
}