func addLeagueGameLinks(league *domain.League, c *gin.Context) {
	gamesURL := fmt.Sprintf("/api/leagues/%d/games", league.ID)
	league.AddLink(relGames, gamesURL)

	if isAuthenticated(c) {
		league.AddLink(relCreateGame, gamesURL)
	}
}
func (ls LeagueService) createLeague(c *gin.Context) {
	var league domain.League

	c.Bind(&league)

	league.ID = 0
	league.Active = true

	ls.doSaveLeague(league, c)
}
func addLeagueLinks(league *domain.League, c *gin.Context) {
	selfURL := fmt.Sprintf("/api/leagues/%d", league.ID)

	league.AddLink(domain.RelSelf, selfURL)

	if isAuthenticated(c) {
		league.AddLink(domain.RelUpdate, selfURL)
	}

	addLeagueGameLinks(league, c)
}
func (dao *LeagueDao) SaveLeague(league domain.League) (*domain.League, error) {
	if league.ID == 0 {
		leagueID, _, _ := datastore.AllocateIDs(dao.Context, EntityLeague, nil, 1)
		league.ID = leagueID
	}

	key := datastore.NewKey(dao.Context, EntityLeague, "", league.ID, nil)

	l, err := dao.save(key, &league)

	if err != nil {
		return nil, err
	}

	savedLeague := l.(*domain.League)

	return savedLeague, err
}