root / GES_PAC / Model / Calibration.cs @ 6f451cc1
Historique | Voir | Annoter | Télécharger (1,631 ko)
1 |
using SQLite; |
---|---|
2 |
using System.ComponentModel.DataAnnotations.Schema; |
3 |
|
4 |
namespace GES_PAC.Model |
5 |
{ |
6 |
public class Calibration |
7 |
{ |
8 |
#region Propri?t?s |
9 |
[PrimaryKey, AutoIncrement] |
10 |
public int Id { get; set; } |
11 |
public int PhaseCalibrationId { get; set; } |
12 |
[ForeignKey("PhaseCalibrationId")] |
13 |
public PhaseCalibration Phase { get; set; } |
14 |
public List<MesureCalibration> Mesures { get; set; } = []; |
15 |
public int JourneeId { get; set; } |
16 |
[ForeignKey("JourneeId")] |
17 |
public Journee Journee { get; set; } |
18 |
#endregion |
19 |
|
20 |
#region Constructeurs |
21 |
public Calibration() { } |
22 |
public Calibration(PhaseCalibration Phase, MesureCalibration Mesure) |
23 |
{ |
24 |
this.Phase = Phase; |
25 |
Mesures = []; |
26 |
Mesures.Add(Mesure); |
27 |
} |
28 |
#endregion |
29 |
public void AddMesure(MesureCalibration mesure) |
30 |
{ |
31 |
mesure.Calibration = this; |
32 |
var index = Mesures.FindIndex(m => m.Type == mesure.Type); |
33 |
if (index != -1) |
34 |
{ |
35 |
Mesures[index] = mesure; |
36 |
return; |
37 |
} |
38 |
Mesures.Add(mesure); |
39 |
} |
40 |
|
41 |
public bool IsComplete() |
42 |
{ |
43 |
return Mesures.Select(m => m.Type).Distinct().ToList().Count == 3; |
44 |
} |
45 |
|
46 |
public List<TypeCalibration> GetTypesDone() |
47 |
{ |
48 |
return Mesures.Select(m => m.Type).Distinct().ToList(); |
49 |
} |
50 |
|
51 |
internal MesureCalibration? getMesureCalibrationByType(TypeCalibration typeCalibration) |
52 |
{ |
53 |
return Mesures.FirstOrDefault(mc => mc.Type == typeCalibration); |
54 |
} |
55 |
} |
56 |
} |