Implemented basic donor deletion

ref #65
This commit is contained in:
Nicolai Ort 2021-01-02 16:45:01 +01:00
parent 3df1db4ad8
commit 61a17b198f
1 changed files with 8 additions and 6 deletions

View File

@ -92,15 +92,17 @@ export class DonorController {
@OnUndefined(204)
@OpenAPI({ description: 'Delete the runner whose id you provided. <br> If no runner with this id exists it will just return 204(no content).' })
async remove(@Param("id") id: number, @QueryParam("force") force: boolean) {
let runner = await this.donorRepository.findOne({ id: id });
if (!runner) { return null; }
const responseRunner = await this.donorRepository.findOne(runner, { relations: ['scans', 'group'] });
let donor = await this.donorRepository.findOne({ id: id });
if (!donor) { return null; }
const responseDonor = await this.donorRepository.findOne(donor);
if (!runner) {
if (!donor) {
throw new RunnerNotFoundError();
}
await this.donorRepository.delete(runner);
return new ResponseDonor(responseRunner);
//TODO: DELETE DONATIONS AND WARN FOR FORCE
await this.donorRepository.delete(donor);
return new ResponseDonor(responseDonor);
}
}