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