Switched the update classes over to the new address implementation
ref #105
This commit is contained in:
parent
2cd15d25e9
commit
d0df5dd641
@ -33,7 +33,7 @@ export class UpdateDonor extends CreateParticipant {
|
|||||||
donor.phone = this.phone;
|
donor.phone = this.phone;
|
||||||
donor.email = this.email;
|
donor.email = this.email;
|
||||||
donor.receiptNeeded = this.receiptNeeded;
|
donor.receiptNeeded = this.receiptNeeded;
|
||||||
donor.address = await this.getAddress();
|
donor.address = this.address;
|
||||||
|
|
||||||
if (this.receiptNeeded == true && this.address == null) {
|
if (this.receiptNeeded == true && this.address == null) {
|
||||||
throw new DonorReceiptAddressNeededError()
|
throw new DonorReceiptAddressNeededError()
|
||||||
|
@ -35,7 +35,7 @@ export class UpdateRunner extends CreateParticipant {
|
|||||||
runner.phone = this.phone;
|
runner.phone = this.phone;
|
||||||
runner.email = this.email;
|
runner.email = this.email;
|
||||||
runner.group = await this.getGroup();
|
runner.group = await this.getGroup();
|
||||||
runner.address = await this.getAddress();
|
runner.address = this.address;
|
||||||
|
|
||||||
return runner;
|
return runner;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { IsInt, IsOptional } from 'class-validator';
|
import { IsInt, IsObject, IsOptional } from 'class-validator';
|
||||||
import { getConnectionManager } from 'typeorm';
|
|
||||||
import { AddressNotFoundError } from '../../../errors/AddressErrors';
|
|
||||||
import { Address } from '../../entities/Address';
|
import { Address } from '../../entities/Address';
|
||||||
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
|
import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
|
||||||
import { CreateRunnerGroup } from '../create/CreateRunnerGroup';
|
import { CreateRunnerGroup } from '../create/CreateRunnerGroup';
|
||||||
@ -20,19 +18,9 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup {
|
|||||||
/**
|
/**
|
||||||
* The updated organisation's address's id.
|
* The updated organisation's address's id.
|
||||||
*/
|
*/
|
||||||
@IsInt()
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
address?: number;
|
@IsObject()
|
||||||
|
address?: Address;
|
||||||
/**
|
|
||||||
* Loads the organisation's address based on it's id.
|
|
||||||
*/
|
|
||||||
public async getAddress(): Promise<Address> {
|
|
||||||
if (!this.address) { return null; }
|
|
||||||
let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
|
|
||||||
if (!address) { throw new AddressNotFoundError; }
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a provided RunnerOrganisation entity based on this.
|
* Updates a provided RunnerOrganisation entity based on this.
|
||||||
@ -41,7 +29,7 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup {
|
|||||||
|
|
||||||
organisation.name = this.name;
|
organisation.name = this.name;
|
||||||
organisation.contact = await this.getContact();
|
organisation.contact = await this.getContact();
|
||||||
organisation.address = await this.getAddress();
|
organisation.address = this.address;
|
||||||
|
|
||||||
return organisation;
|
return organisation;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user