parent
dca9aef258
commit
1c43442300
|
@ -1,4 +1,4 @@
|
|||
import { Entity, Column } from "typeorm";
|
||||
import { Entity, Column, ManyToOne } from "typeorm";
|
||||
import { IsInt, IsNotEmpty, IsPositive,} from "class-validator";
|
||||
import { Donation } from "./Donation";
|
||||
import { Runner } from "./Runner";
|
||||
|
@ -14,7 +14,7 @@ export class DistanceDonation extends Donation {
|
|||
*/
|
||||
@Column()
|
||||
@IsNotEmpty()
|
||||
//TODO:Relation
|
||||
@ManyToOne(() => Runner, runner => runner.distanceDonations)
|
||||
runner: Runner;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ export class DistanceDonation extends Donation {
|
|||
public get amount(): number {
|
||||
let calculatedAmount = -1;
|
||||
try {
|
||||
//calculatedAmount = this.amountPerDistance * this.runner.getDistance();
|
||||
calculatedAmount = this.amountPerDistance * this.runner.getDistance();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { Entity, Column } from "typeorm";
|
||||
import { Entity, Column, OneToMany } from "typeorm";
|
||||
import { IsNotEmpty,} from "class-validator";
|
||||
import { Participant } from "./Participant";
|
||||
import { RunnerGroup } from "./RunnerGroup";
|
||||
import { DistanceDonation } from "./DistanceDonation";
|
||||
|
||||
/**
|
||||
* Defines a runner.
|
||||
|
@ -15,4 +16,7 @@ export class Runner extends Participant {
|
|||
@IsNotEmpty()
|
||||
//TODO:Relation
|
||||
group: RunnerGroup;
|
||||
|
||||
@OneToMany(() => DistanceDonation, distanceDonation => distanceDonation.runner)
|
||||
distanceDonations: DistanceDonation[];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue