diff --git a/src/models/actions/update/UpdateDonor.ts b/src/models/actions/update/UpdateDonor.ts index 8c77ff1..e01f61a 100644 --- a/src/models/actions/update/UpdateDonor.ts +++ b/src/models/actions/update/UpdateDonor.ts @@ -33,7 +33,7 @@ export class UpdateDonor extends CreateParticipant { donor.phone = this.phone; donor.email = this.email; donor.receiptNeeded = this.receiptNeeded; - donor.address = await this.getAddress(); + donor.address = this.address; if (this.receiptNeeded == true && this.address == null) { throw new DonorReceiptAddressNeededError() diff --git a/src/models/actions/update/UpdateRunner.ts b/src/models/actions/update/UpdateRunner.ts index e9e323b..cb24f1f 100644 --- a/src/models/actions/update/UpdateRunner.ts +++ b/src/models/actions/update/UpdateRunner.ts @@ -35,7 +35,7 @@ export class UpdateRunner extends CreateParticipant { runner.phone = this.phone; runner.email = this.email; runner.group = await this.getGroup(); - runner.address = await this.getAddress(); + runner.address = this.address; return runner; } diff --git a/src/models/actions/update/UpdateRunnerOrganisation.ts b/src/models/actions/update/UpdateRunnerOrganisation.ts index 20656ec..6023b84 100644 --- a/src/models/actions/update/UpdateRunnerOrganisation.ts +++ b/src/models/actions/update/UpdateRunnerOrganisation.ts @@ -1,6 +1,4 @@ -import { IsInt, IsOptional } from 'class-validator'; -import { getConnectionManager } from 'typeorm'; -import { AddressNotFoundError } from '../../../errors/AddressErrors'; +import { IsInt, IsObject, IsOptional } from 'class-validator'; import { Address } from '../../entities/Address'; import { RunnerOrganisation } from '../../entities/RunnerOrganisation'; import { CreateRunnerGroup } from '../create/CreateRunnerGroup'; @@ -20,19 +18,9 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup { /** * The updated organisation's address's id. */ - @IsInt() @IsOptional() - address?: number; - - /** - * Loads the organisation's address based on it's id. - */ - public async getAddress(): Promise
{ - if (!this.address) { return null; } - let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address }); - if (!address) { throw new AddressNotFoundError; } - return address; - } + @IsObject() + address?: Address; /** * Updates a provided RunnerOrganisation entity based on this. @@ -41,7 +29,7 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup { organisation.name = this.name; organisation.contact = await this.getContact(); - organisation.address = await this.getAddress(); + organisation.address = this.address; return organisation; }