Added Comments.

ref #11 #13
This commit is contained in:
Nicolai Ort 2020-12-03 17:46:32 +01:00
parent da4597fa62
commit 6d81fc1309
2 changed files with 11 additions and 2 deletions

View File

@ -42,7 +42,7 @@ export class TrackController {
@Body({ validate: true })
track: CreateTrack
) {
return this.trackRepository.save(track.getTrack());
return this.trackRepository.save(track.toTrack());
}
@Put('/:id')

View File

@ -2,15 +2,24 @@ import { IsInt, IsNotEmpty, IsPositive, IsString } from 'class-validator';
import { Track } from './Track';
export class CreateTrack {
/**
* The track's name.
*/
@IsString()
@IsNotEmpty()
name: string;
/**
* The track's distance in meters (must be greater 0).
*/
@IsInt()
@IsPositive()
distance: number;
public getTrack(): Track {
/**
* Converts a Track object based on this.
*/
public toTrack(): Track {
let newTrack: Track = new Track();
newTrack.name = this.name;