Moved all update() and toEntity action model functions to async
ref #76
This commit is contained in:
parent
3f7b0f6563
commit
3deae2bfeb
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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')
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user