parent
97c01ce81a
commit
ed3b55a1e2
|
@ -1,6 +1,6 @@
|
|||
import { IsInt, IsNotEmpty, IsObject } from 'class-validator';
|
||||
import { IsInt, IsPositive } from 'class-validator';
|
||||
import { getConnectionManager } from 'typeorm';
|
||||
import { RunnerOrganisationNotFoundError, RunnerOrganisationWrongTypeError } from '../../../errors/RunnerOrganisationErrors';
|
||||
import { RunnerOrganisationNotFoundError } from '../../../errors/RunnerOrganisationErrors';
|
||||
import { RunnerTeamNeedsParentError } from '../../../errors/RunnerTeamErrors';
|
||||
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
|
||||
import { RunnerTeam } from '../../entities/RunnerTeam';
|
||||
|
@ -19,12 +19,11 @@ export class UpdateRunnerTeam extends CreateRunnerGroup {
|
|||
id: number;
|
||||
|
||||
/**
|
||||
* The updated team's parentGroup.
|
||||
* Just has to contain the organisation's id - everything else won't be checked or changed.
|
||||
* The updated team's parentGroup's id.
|
||||
*/
|
||||
@IsObject()
|
||||
@IsNotEmpty()
|
||||
parentGroup: RunnerOrganisation;
|
||||
@IsInt()
|
||||
@IsPositive()
|
||||
parentGroup: number;
|
||||
|
||||
/**
|
||||
* Loads the updated teams's parentGroup based on it's id.
|
||||
|
@ -33,13 +32,9 @@ export class UpdateRunnerTeam extends CreateRunnerGroup {
|
|||
if (this.parentGroup === undefined || this.parentGroup === null) {
|
||||
throw new RunnerTeamNeedsParentError();
|
||||
}
|
||||
if (!isNaN(this.parentGroup.id)) {
|
||||
let parentGroup = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: this.parentGroup.id });
|
||||
if (!parentGroup) { throw new RunnerOrganisationNotFoundError();; }
|
||||
return parentGroup;
|
||||
}
|
||||
|
||||
throw new RunnerOrganisationWrongTypeError;
|
||||
let parentGroup = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: this.parentGroup });
|
||||
if (!parentGroup) { throw new RunnerOrganisationNotFoundError();; }
|
||||
return parentGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue