everybody loves a refactor
This commit is contained in:
@@ -23,28 +23,19 @@ func NewTeamParticipation(ctx context.Context, tx bun.Tx,
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrap(err, "GetSeason")
|
||||
}
|
||||
if season == nil {
|
||||
return nil, nil, nil, errors.New("season not found")
|
||||
}
|
||||
league, err := GetLeague(ctx, tx, leagueShortName)
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrap(err, "GetLeague")
|
||||
}
|
||||
if league == nil {
|
||||
return nil, nil, nil, errors.New("league not found")
|
||||
}
|
||||
if !season.HasLeague(league.ID) {
|
||||
return nil, nil, nil, errors.New("league is not assigned to the season")
|
||||
return nil, nil, nil, BadRequestNotAssociated("season", "league", seasonShortName, leagueShortName)
|
||||
}
|
||||
team, err := GetTeam(ctx, tx, teamID)
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrap(err, "GetTeam")
|
||||
}
|
||||
if team == nil {
|
||||
return nil, nil, nil, errors.New("team not found")
|
||||
}
|
||||
if team.InSeason(season.ID) {
|
||||
return nil, nil, nil, errors.New("team already in season")
|
||||
return nil, nil, nil, BadRequestAssociated("season", "team", seasonShortName, teamID)
|
||||
}
|
||||
participation := &TeamParticipation{
|
||||
SeasonID: season.ID,
|
||||
|
||||
Reference in New Issue
Block a user