@@ -1,4 +1,4 @@
 | 
				
			|||||||
import { Authorized, Get, JsonController, OnUndefined, Param } from 'routing-controllers';
 | 
					import { Authorized, Delete, Get, JsonController, OnUndefined, Param, QueryParam } from 'routing-controllers';
 | 
				
			||||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
 | 
					import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
 | 
				
			||||||
import { getConnectionManager, Repository } from 'typeorm';
 | 
					import { getConnectionManager, Repository } from 'typeorm';
 | 
				
			||||||
import { DonationNotFoundError } from '../errors/DonationErrors';
 | 
					import { DonationNotFoundError } from '../errors/DonationErrors';
 | 
				
			||||||
@@ -6,6 +6,7 @@ import { DistanceDonation } from '../models/entities/DistanceDonation';
 | 
				
			|||||||
import { Donation } from '../models/entities/Donation';
 | 
					import { Donation } from '../models/entities/Donation';
 | 
				
			||||||
import { ResponseDistanceDonation } from '../models/responses/ResponseDistanceDonation';
 | 
					import { ResponseDistanceDonation } from '../models/responses/ResponseDistanceDonation';
 | 
				
			||||||
import { ResponseDonation } from '../models/responses/ResponseDonation';
 | 
					import { ResponseDonation } from '../models/responses/ResponseDonation';
 | 
				
			||||||
 | 
					import { ResponseEmpty } from '../models/responses/ResponseEmpty';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@JsonController('/donations')
 | 
					@JsonController('/donations')
 | 
				
			||||||
@OpenAPI({ security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
 | 
					@OpenAPI({ security: [{ "AuthToken": [] }, { "RefreshTokenCookie": [] }] })
 | 
				
			||||||
@@ -115,18 +116,19 @@ export class DonationController {
 | 
				
			|||||||
	// 	return (await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
						// 	return (await this.scanRepository.findOne({ id: id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] })).toResponse();
 | 
				
			||||||
	// }
 | 
						// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// @Delete('/:id')
 | 
						@Delete('/:id')
 | 
				
			||||||
	// @Authorized("SCAN:DELETE")
 | 
						@Authorized("DONATION:DELETE")
 | 
				
			||||||
	// @ResponseSchema(ResponseScan)
 | 
						@ResponseSchema(ResponseDonation)
 | 
				
			||||||
	// @ResponseSchema(ResponseEmpty, { statusCode: 204 })
 | 
						@ResponseSchema(ResponseDistanceDonation)
 | 
				
			||||||
	// @OnUndefined(204)
 | 
						@ResponseSchema(ResponseEmpty, { statusCode: 204 })
 | 
				
			||||||
	// @OpenAPI({ description: 'Delete the scan whose id you provided. <br> If no scan with this id exists it will just return 204(no content).' })
 | 
						@OnUndefined(204)
 | 
				
			||||||
	// async remove(@Param("id") id: number, @QueryParam("force") force: boolean) {
 | 
						@OpenAPI({ description: 'Delete the donation whose id you provided. <br> If no donation with this id exists it will just return 204(no content).' })
 | 
				
			||||||
	// 	let scan = await this.scanRepository.findOne({ id: id });
 | 
						async remove(@Param("id") id: number, @QueryParam("force") force: boolean) {
 | 
				
			||||||
	// 	if (!scan) { return null; }
 | 
							let donation = await this.donationRepository.findOne({ id: id });
 | 
				
			||||||
	// 	const responseScan = await this.scanRepository.findOne({ id: scan.id }, { relations: ['runner', 'track', 'runner.scans', 'runner.scans.track', 'card', 'station'] });
 | 
							if (!donation) { return null; }
 | 
				
			||||||
 | 
							const responseScan = await this.donationRepository.findOne({ id: donation.id }, { relations: ['runner', 'donor', 'runner.scans', 'runner.scans.track'] });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 	await this.scanRepository.delete(scan);
 | 
							await this.donationRepository.delete(donation);
 | 
				
			||||||
	// 	return responseScan.toResponse();
 | 
							return responseScan.toResponse();
 | 
				
			||||||
	// }
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user