예제 #1
0
func (ls LeagueService) createLeague(c *gin.Context) {
	var league domain.League

	c.Bind(&league)

	league.ID = 0
	league.Active = true

	ls.doSaveLeague(league, c)
}
예제 #2
0
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
}