Passed
Push — master ( 3a2d3a...97549a )
by Mathieu
01:48
created

Shooting.update   A

Complexity

Conditions 1

Size

Total Lines 9
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
1
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
2
import { School } from './School.entity';
3
4
export enum ShootingStatus {
5
  ENABLED = 'enabled',
6
  DISABLED = 'disabled'
7
}
8
9
@Entity()
10
export class Shooting {
11
  @PrimaryGeneratedColumn('uuid')
12
  private id: string;
13
14
  @Column({ type: 'varchar', nullable: false })
15
  private name: string;
16
17
  @Column({ type: 'date', nullable: false })
18
  private shootingDate: Date;
19
20
  @Column({ type: 'date', nullable: false })
21
  private closingDate: Date;
22
23
  @Column('enum', { enum: ShootingStatus, nullable: false, default: ShootingStatus.DISABLED })
24
  private status: ShootingStatus;
25
26
  @ManyToOne(() => School, { nullable: false, onDelete: 'CASCADE' })
27
  private school: School;
28
29
  constructor(
30
    name: string,
31
    shootingDate: Date,
32
    closingDate: Date,
33
    status: ShootingStatus,
34
    school: School
35
  ) {
36
    this.name = name;
37
    this.shootingDate = shootingDate;
38
    this.closingDate = closingDate;
39
    this.status = status;
40
    this.school = school;
41
  }
42
43
  public getId(): string {
44
    return this.id;
45
  }
46
47
  public getName(): string {
48
    return this.name;
49
  }
50
51
  public getShootingDate(): Date {
52
    return this.shootingDate;
53
  }
54
55
  public getClosingDate(): Date {
56
    return this.closingDate;
57
  }
58
59
  public getSchool(): School {
60
    return this.school;
61
  }
62
63
  public getStatus(): ShootingStatus {
64
    return this.status;
65
  }
66
67
  public update(
68
    name: string,
69
    shootingDate: Date,
70
    closingDate: Date,
71
  ): void {
72
    this.name = name;
73
    this.shootingDate = shootingDate;
74
    this.closingDate = closingDate;
75
  }
76
}
77