diff --git a/api/src/pilot/info/pilot-info.dto.ts b/api/src/pilot/info/pilot-info.dto.ts new file mode 100644 index 0000000..db9b30f --- /dev/null +++ b/api/src/pilot/info/pilot-info.dto.ts @@ -0,0 +1,11 @@ +export class PilotInfoDto { + id: string; + firstName: string; + lastName: string; + address: string; + city: string; + state: string; + postalCode: string; + email?: string; + phone?: string; +} diff --git a/api/src/pilot/info/pilot-info.entity.ts b/api/src/pilot/info/pilot-info.entity.ts new file mode 100644 index 0000000..edf1b85 --- /dev/null +++ b/api/src/pilot/info/pilot-info.entity.ts @@ -0,0 +1,13 @@ +export class PilotInfoEntity { + partitionKey: string; + rowKey: string; + id: string; + firstName: string; + lastName: string; + address: string; + city: string; + state: string; + postalCode: string; + email?: string; + phone?: string; +} diff --git a/api/src/pilot/info/pilot-info.service.ts b/api/src/pilot/info/pilot-info.service.ts new file mode 100644 index 0000000..18818fa --- /dev/null +++ b/api/src/pilot/info/pilot-info.service.ts @@ -0,0 +1,52 @@ +import { Injectable } from '@nestjs/common'; +// import { Repository, InjectRepository } from '@nestjs/azure-database'; +import { PilotInfoDto } from './pilot-info.dto'; +import { PilotInfoEntity } from './pilot-info.entity'; +import { TableClient, TableService } from '@noahspan/noahspan-modules'; + +@Injectable() +export class PilotInfoService { + private readonly partitionKey: string = 'info'; + + constructor( + // @InjectRepository(PilotInfo) + // private readonly pilotInfoRepository: Repository + private readonly tableService: TableService + ) {} + + // async find(rowKey: string): Promise { + // return await this.pilotInfoRepository.find(this.partitionKey, rowKey); + // } + + // async findAll(): Promise { + // return await this.pilotInfoRepository.findAll(); + // } + + async create(pilotInfoData: PilotInfoDto): Promise { + const client: TableClient = + await this.tableService.getTableClient('Pilots'); + const pilotInfo: PilotInfoEntity = new PilotInfoEntity(); + + Object.assign(pilotInfo, pilotInfoData); + pilotInfo.partitionKey = 'pilot'; + pilotInfo.rowKey = pilotInfo.id; + console.log(pilotInfo); + try { + await client.createEntity(pilotInfo); + } catch (error) { + return error; + } + } + + // async update(rowKey: string, pilotInfo: PilotInfo): Promise { + // return await this.pilotInfoRepository.update( + // this.partitionKey, + // rowKey, + // pilotInfo + // ); + // } + + // async delete(rowKey: string): Promise { + // await this.pilotInfoRepository.delete(this.partitionKey, rowKey); + // } +}