diff --git a/ui/hv2-ui/src/app/tenant-details/tenant-details.component.html b/ui/hv2-ui/src/app/tenant-details/tenant-details.component.html index 91014e6..231c64c 100644 --- a/ui/hv2-ui/src/app/tenant-details/tenant-details.component.html +++ b/ui/hv2-ui/src/app/tenant-details/tenant-details.component.html @@ -60,6 +60,15 @@ IBAN +
+ + Account ID + + + + Account Description + +
diff --git a/ui/hv2-ui/src/app/tenant-details/tenant-details.component.ts b/ui/hv2-ui/src/app/tenant-details/tenant-details.component.ts index a98b486..9167857 100644 --- a/ui/hv2-ui/src/app/tenant-details/tenant-details.component.ts +++ b/ui/hv2-ui/src/app/tenant-details/tenant-details.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { TenantService } from '../data-object-service'; -import { Tenant } from '../data-objects'; +import { AccountService, TenantService } from '../data-object-service'; +import { Account, Tenant } from '../data-objects'; import { MessageService } from '../message.service'; import { Location } from '@angular/common' @@ -28,9 +28,15 @@ export class TenantDetailsComponent implements OnInit { account: 0 } + account: Account = { + id: 0, + description: '' + } + constructor( private tenantService: TenantService, + private accountService: AccountService, private messageService: MessageService, private route: ActivatedRoute, private location: Location @@ -41,17 +47,26 @@ export class TenantDetailsComponent implements OnInit { const id = +this.route.snapshot.paramMap.get('id') if (id != 0) { this.tenant = await this.tenantService.getTenant(id) + this.account = await this.accountService.getAccount(this.tenant.account) } } catch (err) { this.messageService.add(JSON.stringify(err, undefined, 4)) } } - saveTenant() { + async saveTenant() { this.messageService.add("saveTenant") this.messageService.add(JSON.stringify(this.tenant, undefined, 4)) if (this.tenant.id == 0) { this.messageService.add("about to insert new tenant") + this.account = { + "id": 0, + "description": `account_${this.tenant.firstname}_${this.tenant.lastname}` + } + this.account = await this.accountService.postAccount(this.account) + this.tenant.account = this.account.id + this.tenant = await this.tenantService.postTenant(this.tenant) + this.messageService.add(`Successfully added account with id ${this.account.id} and tenant with id ${this.tenant.id}`) } else { this.messageService.add("about to update existing tenant") }