Added basic runner updateing

ref #65
This commit is contained in:
2021-01-02 16:55:27 +01:00
parent 557608e318
commit ab67e5f4aa
3 changed files with 48 additions and 10 deletions

View File

@@ -12,7 +12,7 @@ export class CreateDonor extends CreateParticipant {
*/
@IsBoolean()
@IsOptional()
receiptNeeded: boolean = false;
receiptNeeded?: boolean = false;
/**
* Creates a new Donor entity from this.

View File

@@ -0,0 +1,39 @@
import { IsBoolean, IsInt, IsOptional } from 'class-validator';
import { Donor } from '../entities/Donor';
import { CreateParticipant } from './CreateParticipant';
/**
* This class is used to update a Donor entity (via put request).
*/
export class UpdateDonor extends CreateParticipant {
/**
* The updated donor'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;
/**
* Does the updated donor need a receipt?
*/
@IsBoolean()
@IsOptional()
receiptNeeded?: boolean;
/**
* Updates a provided Donor entity based on this.
*/
public async updateDonor(donor: Donor): Promise<Donor> {
donor.firstname = this.firstname;
donor.middlename = this.middlename;
donor.lastname = this.lastname;
donor.phone = this.phone;
donor.email = this.email;
donor.receiptNeeded = this.receiptNeeded;
donor.address = await this.getAddress();
return donor;
}
}