| @@ -12,7 +12,7 @@ export class CreateDonor extends CreateParticipant { | ||||
|      */ | ||||
|     @IsBoolean() | ||||
|     @IsOptional() | ||||
|     receiptNeeded: boolean = false; | ||||
|     receiptNeeded?: boolean = false; | ||||
|  | ||||
|     /** | ||||
|      * Creates a new Donor entity from this. | ||||
|   | ||||
							
								
								
									
										39
									
								
								src/models/actions/UpdateDonor.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/models/actions/UpdateDonor.ts
									
									
									
									
									
										Normal 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; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user