37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { IsInt, IsObject, IsOptional } from 'class-validator';
|
|
import { Address } from '../../entities/Address';
|
|
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
|
|
import { CreateRunnerGroup } from '../create/CreateRunnerGroup';
|
|
|
|
/**
|
|
* This class is used to update a RunnerOrganisation entity (via put request).
|
|
*/
|
|
export class UpdateRunnerOrganisation extends CreateRunnerGroup {
|
|
|
|
/**
|
|
* The updated orgs's id.
|
|
* This shouldn't have changed but it is here in case anyone ever wants to enable id changes (whyever they would want to).
|
|
*/
|
|
@IsInt()
|
|
id: number;
|
|
|
|
/**
|
|
* The updated organisation's address.
|
|
*/
|
|
@IsOptional()
|
|
@IsObject()
|
|
address?: Address;
|
|
|
|
/**
|
|
* Updates a provided RunnerOrganisation entity based on this.
|
|
*/
|
|
public async update(organisation: RunnerOrganisation): Promise<RunnerOrganisation> {
|
|
|
|
organisation.name = this.name;
|
|
organisation.contact = await this.getContact();
|
|
organisation.address = this.address;
|
|
Address.validate(organisation.address);
|
|
|
|
return organisation;
|
|
}
|
|
} |