@@ -1,8 +1,10 @@
|
||||
import { IsObject, IsOptional } from 'class-validator';
|
||||
import { IsBoolean, IsObject, IsOptional } from 'class-validator';
|
||||
import * as uuid from 'uuid';
|
||||
import { Address } from '../../entities/Address';
|
||||
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
|
||||
import { CreateRunnerGroup } from './CreateRunnerGroup';
|
||||
|
||||
|
||||
/**
|
||||
* This classed is used to create a new RunnerOrganisation entity from a json body (post request).
|
||||
*/
|
||||
@@ -14,6 +16,13 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
|
||||
@IsObject()
|
||||
address?: Address;
|
||||
|
||||
/**
|
||||
* Is registration enabled for the new organisation?
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
registrtionEnabled?: boolean = false;
|
||||
|
||||
/**
|
||||
* Creates a new RunnerOrganisation entity from this.
|
||||
*/
|
||||
@@ -25,6 +34,10 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
|
||||
newRunnerOrganisation.address = this.address;
|
||||
Address.validate(newRunnerOrganisation.address);
|
||||
|
||||
if (this.registrtionEnabled) {
|
||||
newRunnerOrganisation.key = uuid.v4().toUpperCase();
|
||||
}
|
||||
|
||||
return newRunnerOrganisation;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { IsInt, IsObject, IsOptional } from 'class-validator';
|
||||
import { IsBoolean, IsInt, IsNotEmpty, IsObject, IsOptional } from 'class-validator';
|
||||
import * as uuid from 'uuid';
|
||||
import { Address } from '../../entities/Address';
|
||||
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
|
||||
import { CreateRunnerGroup } from '../create/CreateRunnerGroup';
|
||||
@@ -22,6 +23,13 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup {
|
||||
@IsObject()
|
||||
address?: Address;
|
||||
|
||||
/**
|
||||
* Is registration enabled for the updated organisation?
|
||||
*/
|
||||
@IsNotEmpty()
|
||||
@IsBoolean()
|
||||
registrtionEnabled: boolean;
|
||||
|
||||
/**
|
||||
* Updates a provided RunnerOrganisation entity based on this.
|
||||
*/
|
||||
@@ -33,6 +41,13 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup {
|
||||
else { organisation.address = this.address; }
|
||||
Address.validate(organisation.address);
|
||||
|
||||
if (this.registrtionEnabled) {
|
||||
organisation.key = uuid.v4().toUpperCase();
|
||||
}
|
||||
else {
|
||||
organisation.key = null;
|
||||
}
|
||||
|
||||
return organisation;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user