From 456d9ce4d096a910b621e22f00b965a432c37cc5 Mon Sep 17 00:00:00 2001 From: Mariela Date: Mon, 22 Aug 2022 15:06:44 -0600 Subject: [PATCH] deleteTenant function community --- .../src/communities/communities.controller.ts | 9 +++++++++ .../src/communities/communities.service.ts | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/servicio-comunidad-viviendas/src/communities/communities.controller.ts b/servicio-comunidad-viviendas/src/communities/communities.controller.ts index 1133b4d0..d8302399 100644 --- a/servicio-comunidad-viviendas/src/communities/communities.controller.ts +++ b/servicio-comunidad-viviendas/src/communities/communities.controller.ts @@ -63,4 +63,13 @@ export class CommunitiesController { let number_house = body['number_house']; return this.communitiesService.saveTenant(id, number_house, tenant_id); } + + @MessagePattern({ cmd: 'deleteTenant' }) + deleteTenant(@Payload() body: string) { + + let id = body['_id']; + let tenant_id = body['tenant_id']; + let number_house = body['number_house']; + return this.communitiesService.deleteTenant(id, number_house, tenant_id); + } } diff --git a/servicio-comunidad-viviendas/src/communities/communities.service.ts b/servicio-comunidad-viviendas/src/communities/communities.service.ts index fa7ed5b7..b718a024 100644 --- a/servicio-comunidad-viviendas/src/communities/communities.service.ts +++ b/servicio-comunidad-viviendas/src/communities/communities.service.ts @@ -111,15 +111,12 @@ export class CommunitiesService { await community.houses.map(house => { if (house.number_house == number_house && house.tenants.tenant_id == tenant_id) { - house.tenants = null; + house.tenants.tenant_id = ""; house.state = "desocupada" - } return house; }) - console.log(community.houses) - return await this.communityModel.findOneAndUpdate({ _id: id }, community, { new: true, });