root / GES_PAC / Model / Journee.cs @ 3fef487c
Historique | Voir | Annoter | Télécharger (3,058 ko)
1 | 6f451cc1 | lbihannic | using SQLite; |
---|---|---|---|
2 | using System.ComponentModel.DataAnnotations.Schema; |
||
3 | |||
4 | 65ad7e66 | Lucas Bihannic | namespace GES_PAC.Model |
5 | { |
||
6 | public class Journee |
||
7 | { |
||
8 | 5d673ce0 | Lucas Bihannic | #region Propriétés |
9 | 6f451cc1 | lbihannic | [PrimaryKey, AutoIncrement] |
10 | public int Id { get; set; } |
||
11 | public int PersonneId { get; set; } |
||
12 | [ForeignKey("PersonneId")] |
||
13 | 65ad7e66 | Lucas Bihannic | public Personne Responsable { get; set; } |
14 | 6f451cc1 | lbihannic | public int LieuId { get; set; } |
15 | [ForeignKey("LieuId")] |
||
16 | 65ad7e66 | Lucas Bihannic | public Lieu Lieu { get; set; } |
17 | public DateTime Date { get; set; } |
||
18 | public string Regime { get; set; } |
||
19 | 6f451cc1 | lbihannic | public List<Serie> Series { get; set; } = []; |
20 | public List<Calibration> Calibrations { get; set; } = []; |
||
21 | 5d673ce0 | Lucas Bihannic | #endregion |
22 | |||
23 | #region Constructeurs |
||
24 | 6f451cc1 | lbihannic | public Journee(){} |
25 | 5d673ce0 | Lucas Bihannic | public Journee(DateTime Date, Personne Responsable, Lieu Lieu, string Regime) |
26 | 65ad7e66 | Lucas Bihannic | { |
27 | this.Responsable = Responsable; |
||
28 | this.Lieu = Lieu; |
||
29 | this.Date = Date; |
||
30 | this.Regime = Regime; |
||
31 | 5d673ce0 | Lucas Bihannic | Series = []; |
32 | Calibrations = []; |
||
33 | } |
||
34 | #endregion |
||
35 | |||
36 | #region Méthodes |
||
37 | 09d4a0de | lbihannic | |
38 | 12ddf7ef | lbihannic | public void AddSet(Serie set) |
39 | 09d4a0de | lbihannic | { |
40 | 6f451cc1 | lbihannic | set.Journee = this; |
41 | 09d4a0de | lbihannic | Series.Add(set); |
42 | 5d673ce0 | Lucas Bihannic | } |
43 | 6f451cc1 | lbihannic | public List<TypeCalibration> GetMissingCalibrationByPhase(PhaseCalibration phase) |
44 | 5d673ce0 | Lucas Bihannic | { |
45 | 6f451cc1 | lbihannic | if (phase == null) |
46 | return TypeCalibration.All; |
||
47 | 5d673ce0 | Lucas Bihannic | |
48 | 6f451cc1 | lbihannic | var calibPhase = Calibrations.FirstOrDefault(c => c.Phase == phase); |
49 | 5d673ce0 | Lucas Bihannic | |
50 | 6f451cc1 | lbihannic | if (calibPhase == null || calibPhase.IsComplete()) |
51 | 5d673ce0 | Lucas Bihannic | return TypeCalibration.All; |
52 | 6f451cc1 | lbihannic | |
53 | return TypeCalibration.All.Except(calibPhase.GetTypesDone()).ToList(); |
||
54 | 65ad7e66 | Lucas Bihannic | } |
55 | 6f451cc1 | lbihannic | |
56 | |||
57 | public Serie? GetCurrentSet() |
||
58 | ba296a27 | lbihannic | { |
59 | 6f451cc1 | lbihannic | return Series?.LastOrDefault(); |
60 | ba296a27 | lbihannic | } |
61 | 4e39035b | lbihannic | public bool HasAnySet() |
62 | { |
||
63 | return Series.Count > 0; |
||
64 | } |
||
65 | 957b1f34 | lbihannic | internal int GetSetCount() |
66 | { |
||
67 | return Series.Count; |
||
68 | } |
||
69 | internal int GetDayAnimalCount() |
||
70 | { |
||
71 | return Series.Sum(s => s.GetAnimalCount()); |
||
72 | } |
||
73 | |||
74 | internal int GetDayMeasureCount() |
||
75 | { |
||
76 | return Series.Sum(s => s.GetMeasureCount()); |
||
77 | } |
||
78 | |||
79 | internal int GetDayBehaviourCount() |
||
80 | { |
||
81 | return Series.Sum(s => s.GetBehaviourCount()); |
||
82 | } |
||
83 | internal Calibration GetLastCalibration() |
||
84 | { |
||
85 | return Calibrations.Last(); |
||
86 | } |
||
87 | internal Calibration GetDebutCalibration() |
||
88 | { |
||
89 | 6f451cc1 | lbihannic | return Calibrations.FirstOrDefault(c => c.Phase?.Value == PhaseCalibration.DEBUT.Value); |
90 | acb5dd8c | lbihannic | } |
91 | internal bool IsCalibrationComplete(PhaseCalibration pc) |
||
92 | { |
||
93 | 6f451cc1 | lbihannic | return Calibrations?.FirstOrDefault(c => c.Phase == pc)?.IsComplete() ?? false; |
94 | acb5dd8c | lbihannic | } |
95 | internal bool IsComplete() |
||
96 | { |
||
97 | 6f451cc1 | lbihannic | return Calibrations?.FirstOrDefault(c => c.Phase == PhaseCalibration.FIN)?.IsComplete() ?? false; |
98 | } |
||
99 | |||
100 | internal void AddCalibration(Calibration calibration) |
||
101 | { |
||
102 | calibration.Journee = this; |
||
103 | Calibrations.Add(calibration); |
||
104 | 957b1f34 | lbihannic | } |
105 | 5d673ce0 | Lucas Bihannic | #endregion |
106 | 65ad7e66 | Lucas Bihannic | } |
107 | } |