Moved all update() and toEntity action model functions to async

ref #76
This commit is contained in:
Nicolai Ort 2021-01-10 16:53:59 +01:00
parent 3f7b0f6563
commit 3deae2bfeb
5 changed files with 5 additions and 5 deletions

View File

@ -54,7 +54,7 @@ export class RunnerTeamController {
async post(@Body({ validate: true }) createRunnerTeam: CreateRunnerTeam) { async post(@Body({ validate: true }) createRunnerTeam: CreateRunnerTeam) {
let runnerTeam; let runnerTeam;
try { try {
runnerTeam = await createRunnerTeam.toRunnerTeam(); runnerTeam = await createRunnerTeam.toEntity();
} catch (error) { } catch (error) {
throw error; throw error;
} }

View File

@ -55,7 +55,7 @@ export class TrackController {
@Body({ validate: true }) @Body({ validate: true })
track: CreateTrack track: CreateTrack
) { ) {
return new ResponseTrack(await this.trackRepository.save(track.toEntity())); return new ResponseTrack(await this.trackRepository.save(await track.toEntity()));
} }
@Put('/:id') @Put('/:id')

View File

@ -56,7 +56,7 @@ export class CreateAddress {
/** /**
* Creates a new Address entity from this. * Creates a new Address entity from this.
*/ */
public toEntity(): Address { public async toEntity(): Promise<Address> {
let newAddress: Address = new Address(); let newAddress: Address = new Address();
newAddress.address1 = this.address1; newAddress.address1 = this.address1;

View File

@ -37,7 +37,7 @@ export class CreateRunnerTeam extends CreateRunnerGroup {
/** /**
* Creates a new RunnerTeam entity from this. * Creates a new RunnerTeam entity from this.
*/ */
public async toRunnerTeam(): Promise<RunnerTeam> { public async toEntity(): Promise<RunnerTeam> {
let newRunnerTeam: RunnerTeam = new RunnerTeam(); let newRunnerTeam: RunnerTeam = new RunnerTeam();
newRunnerTeam.name = this.name; newRunnerTeam.name = this.name;

View File

@ -37,7 +37,7 @@ export class UpdateTrack {
* Update a Track entity based on this. * Update a Track entity based on this.
* @param track The track that shall be updated. * @param track The track that shall be updated.
*/ */
public update(track: Track): Track { public async update(track: Track): Promise<Track> {
track.name = this.name; track.name = this.name;
track.distance = this.distance; track.distance = this.distance;
track.minimumLapTime = this.minimumLapTime; track.minimumLapTime = this.minimumLapTime;