adding pilot
This commit is contained in:
11
api/src/pilot/info/pilot-info.dto.ts
Normal file
11
api/src/pilot/info/pilot-info.dto.ts
Normal 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;
|
||||||
|
}
|
||||||
13
api/src/pilot/info/pilot-info.entity.ts
Normal file
13
api/src/pilot/info/pilot-info.entity.ts
Normal 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;
|
||||||
|
}
|
||||||
52
api/src/pilot/info/pilot-info.service.ts
Normal file
52
api/src/pilot/info/pilot-info.service.ts
Normal 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);
|
||||||
|
// }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user