From 42d4a6a0bf431f9127a0ab7aff66d9558a23effb Mon Sep 17 00:00:00 2001 From: Nael-Alshowaikh <153004766+Nael-Alshowaikh@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:39:55 +0200 Subject: [PATCH] fixed put function before moving the uc --- .../api/organisation.controller.ts | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/modules/organisation/api/organisation.controller.ts b/src/modules/organisation/api/organisation.controller.ts index 6a72c45a7..c8d818af5 100644 --- a/src/modules/organisation/api/organisation.controller.ts +++ b/src/modules/organisation/api/organisation.controller.ts @@ -103,22 +103,19 @@ export class OrganisationController { throw new NotFoundException(`Organisation with ID ${params.organisationId} not found`); } - const updatedOrganisation: Organisation = Organisation.construct( - params.organisationId, - existingOrganisation.createdAt, - new Date(), - body.administriertVon, - body.zugehoerigZu, - body.kennung, - body.name, - body.namensergaenzung, - body.kuerzel, - body.typ, - body.traegerschaft, - ); - ///!!! Note to self the find by id will be called twice here but no other way? unless created at is optional + existingOrganisation.id = params.organisationId; + existingOrganisation.administriertVon = body.administriertVon; + existingOrganisation.zugehoerigZu = body.zugehoerigZu; + existingOrganisation.kennung = body.kennung; + existingOrganisation.name = body.name; + existingOrganisation.namensergaenzung = body.namensergaenzung; + existingOrganisation.kuerzel = body.kuerzel; + existingOrganisation.typ = body.typ; + existingOrganisation.traegerschaft = body.traegerschaft; + existingOrganisation.updatedAt = new Date(); + const response: Organisation | SchulConnexError | OrganisationSpecificationError = - await this.uc.updateOrganisation(updatedOrganisation); + await this.uc.updateOrganisation(existingOrganisation); if (response instanceof Organisation) { return new OrganisationResponse(response);