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