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 { getConnectionManager } from 'typeorm';
|
||||||
import { RunnerOrganisationNotFoundError, RunnerOrganisationWrongTypeError } from '../../../errors/RunnerOrganisationErrors';
|
import { RunnerOrganisationNotFoundError } from '../../../errors/RunnerOrganisationErrors';
|
||||||
import { RunnerTeamNeedsParentError } from '../../../errors/RunnerTeamErrors';
|
import { RunnerTeamNeedsParentError } from '../../../errors/RunnerTeamErrors';
|
||||||
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
|
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
|
||||||
import { RunnerTeam } from '../../entities/RunnerTeam';
|
import { RunnerTeam } from '../../entities/RunnerTeam';
|
||||||
@ -19,12 +19,11 @@ export class UpdateRunnerTeam extends CreateRunnerGroup {
|
|||||||
id: number;
|
id: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The updated team's parentGroup.
|
* The updated team's parentGroup's id.
|
||||||
* Just has to contain the organisation's id - everything else won't be checked or changed.
|
|
||||||
*/
|
*/
|
||||||
@IsObject()
|
@IsInt()
|
||||||
@IsNotEmpty()
|
@IsPositive()
|
||||||
parentGroup: RunnerOrganisation;
|
parentGroup: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the updated teams's parentGroup based on it's id.
|
* 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) {
|
if (this.parentGroup === undefined || this.parentGroup === null) {
|
||||||
throw new RunnerTeamNeedsParentError();
|
throw new RunnerTeamNeedsParentError();
|
||||||
}
|
}
|
||||||
if (!isNaN(this.parentGroup.id)) {
|
let parentGroup = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: this.parentGroup });
|
||||||
let parentGroup = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: this.parentGroup.id });
|
if (!parentGroup) { throw new RunnerOrganisationNotFoundError();; }
|
||||||
if (!parentGroup) { throw new RunnerOrganisationNotFoundError();; }
|
return parentGroup;
|
||||||
return parentGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new RunnerOrganisationWrongTypeError;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user