diff --git a/paperless-backend/src/settings/settings.controller.ts b/paperless-backend/src/settings/settings.controller.ts index c2cea5c..a2f7e26 100644 --- a/paperless-backend/src/settings/settings.controller.ts +++ b/paperless-backend/src/settings/settings.controller.ts @@ -376,13 +376,26 @@ export class SettingsController { async updateCorrespondentSetting(@Param('id') id: string, @Body() body: { agrarmonitorId: number | null }) { const corrId = parseInt(id, 10); let setting = await this.corrSettingRepo.findOneBy({ CorrespondentId: corrId }); - + if (!setting) { setting = this.corrSettingRepo.create({ CorrespondentId: corrId, AgrarmonitorId: body.agrarmonitorId }); } else { setting.AgrarmonitorId = body.agrarmonitorId; } - + return this.corrSettingRepo.save(setting); } + + // === Betriebe === + @Get('clients') + async getClients() { + return this.clientRepo.find({ order: { Name: 'ASC' } }); + } + + @Put('clients/:id') + async updateClient(@Param('id') id: string, @Body() body: { AgrarmonitorBetriebId: number | null }) { + const clientId = parseInt(id, 10); + await this.clientRepo.update(clientId, { AgrarmonitorBetriebId: body.AgrarmonitorBetriebId ?? null }); + return this.clientRepo.findOneByOrFail({ Id: clientId }); + } }