adding pilot

This commit is contained in:
2024-08-16 19:27:22 -05:00
parent 9e1e69d996
commit ad3f1105c4
3 changed files with 76 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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<PilotInfo>
private readonly tableService: TableService
) {}
// async find(rowKey: string): Promise<PilotInfo> {
// return await this.pilotInfoRepository.find(this.partitionKey, rowKey);
// }
// async findAll(): Promise<PilotInfo[]> {
// return await this.pilotInfoRepository.findAll();
// }
async create(pilotInfoData: PilotInfoDto): Promise<void> {
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<PilotInfo> {
// return await this.pilotInfoRepository.update(
// this.partitionKey,
// rowKey,
// pilotInfo
// );
// }
// async delete(rowKey: string): Promise<void> {
// await this.pilotInfoRepository.delete(this.partitionKey, rowKey);
// }
}