From 0e9aa692a64f1ac6341f4ae55501a89fb59ac3eb Mon Sep 17 00:00:00 2001 From: Vins Date: Wed, 29 May 2024 09:33:38 +0200 Subject: [PATCH 1/2] Added office to customer creation --- src/app/api/notary/CustomersController.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/api/notary/CustomersController.ts b/src/app/api/notary/CustomersController.ts index 9de0192c..a6e1d159 100644 --- a/src/app/api/notary/CustomersController.ts +++ b/src/app/api/notary/CustomersController.ts @@ -60,6 +60,8 @@ export default class CustomersController extends ApiController { try { //init IUser resource with request body values const customerEntity = Customer.hydrate(req.body); + const officeId: string = req.body.user.office_Id; + customerEntity.office = { uid: officeId } as any; //validate user try { await validateOrReject(customerEntity, { groups: ["createCustomer"], forbidUnknownValues: false }); From 752fe3b96cb0e1d8b0de92d331f0bea149717fac Mon Sep 17 00:00:00 2001 From: Vins Date: Wed, 29 May 2024 23:21:46 +0200 Subject: [PATCH 2/2] Remove customer finished --- src/app/api/notary/CustomersController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/api/notary/CustomersController.ts b/src/app/api/notary/CustomersController.ts index a6e1d159..83d3d1c9 100644 --- a/src/app/api/notary/CustomersController.ts +++ b/src/app/api/notary/CustomersController.ts @@ -34,8 +34,8 @@ export default class CustomersController extends ApiController { } const officeId: string = req.body.user.office_Id; - if (query.where?.office_folders) delete query.where.office_folders; - const customerWhereInput: Prisma.CustomersWhereInput = { ...query.where, office_folders: { some: { office_uid: officeId } } }; + if (query.where?.office) delete query.where.office; + const customerWhereInput: Prisma.CustomersWhereInput = { ...query.where, office: { uid: officeId } }; query.where = customerWhereInput; //call service to get prisma entity