commit 6f451cc15082223f16b7f12c0a8127406dae6220
Author: lbihannic <lucas.bihannic@inrae.fr>
Date:   Thu Apr 24 14:10:43 2025 +0200

    add SQLite persistance support

diff --git a/GES_PAC/Model/Journee.cs b/GES_PAC/Model/Journee.cs
index a0ccf5f..36547f4 100644
--- a/GES_PAC/Model/Journee.cs
+++ b/GES_PAC/Model/Journee.cs
@@ -1,18 +1,27 @@
+using SQLite;
+using System.ComponentModel.DataAnnotations.Schema;
+
 namespace GES_PAC.Model
 {
     public class Journee
     {
         #region Propriétés
+        [PrimaryKey, AutoIncrement]
+        public int Id { get; set; }
+        public int PersonneId { get; set; }
+        [ForeignKey("PersonneId")]
         public Personne Responsable { get; set; }
+        public int LieuId { get; set; }
+        [ForeignKey("LieuId")]
         public Lieu Lieu { get; set; }
-        public long Id { get; set; }
         public DateTime Date { get; set; }
         public string Regime { get; set; }
-        public List<Serie> Series { get; set; }
-        public List<Calibration> Calibrations { get; set; }
+        public List<Serie> Series { get; set; } = [];
+        public List<Calibration> Calibrations { get; set; } = [];
         #endregion
 
         #region Constructeurs
+        public Journee(){}
         public Journee(DateTime Date, Personne Responsable, Lieu Lieu, string Regime)
         {
             this.Responsable = Responsable;
@@ -25,51 +34,29 @@ namespace GES_PAC.Model
         #endregion
 
         #region Méthodes
-        public bool AddCalibration(MesureCalibration mesureCalibration, PhaseCalibration phaseCalibration)
-        {
-            var existing = Calibrations.FirstOrDefault(c => c.Phase == phaseCalibration);
-
-            if (existing == null)
-            {
-                Calibrations.Add(new Calibration(phaseCalibration, mesureCalibration));
-                return false;
-            }
-
-            existing.AddMesure(mesureCalibration);
-            return existing.IsComplete();
-        }
 
         public void AddSet(Serie set)
         {
+            set.Journee = this;
             Series.Add(set);
         }
-
-        public PhaseCalibration GetCurrentPhase()
+        public List<TypeCalibration> GetMissingCalibrationByPhase(PhaseCalibration phase)
         {
-            if (Series.Count == 0)
-            {
-                return PhaseCalibration.DEBUT;
-            }
-            return PhaseCalibration.FIN;
-        }
+            if (phase == null)
+                return TypeCalibration.All;
 
-        public Calibration GetCurrentCalibration()
-        {
-            return Calibrations.FirstOrDefault(c => c.Phase == GetCurrentPhase());
-        }
+            var calibPhase = Calibrations.FirstOrDefault(c => c.Phase == phase);
 
-        public List<TypeCalibration> GetCurrentMissingCalibration()
-        {
-            if (Calibrations.Count == 0 || Calibrations.Last().IsComplete())
-            {
+            if (calibPhase == null || calibPhase.IsComplete())
                 return TypeCalibration.All;
-            }
-            return TypeCalibration.All.Except(Calibrations.Last().GetTypesDone()).ToList();
+
+            return TypeCalibration.All.Except(calibPhase.GetTypesDone()).ToList();
         }
-        
-        public Serie GetCurrentSet()
+
+
+        public Serie? GetCurrentSet()
         {
-            return Series.LastOrDefault();
+            return Series?.LastOrDefault();
         }
         public bool HasAnySet()
         {
@@ -99,15 +86,21 @@ namespace GES_PAC.Model
         }
         internal Calibration GetDebutCalibration()
         {
-            return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.DEBUT);
+            return Calibrations.FirstOrDefault(c => c.Phase?.Value == PhaseCalibration.DEBUT.Value);
         }
         internal bool IsCalibrationComplete(PhaseCalibration pc)
         {
-            return Calibrations.FirstOrDefault(c => c.Phase == pc)?.IsComplete() ?? false;
+            return Calibrations?.FirstOrDefault(c => c.Phase == pc)?.IsComplete() ?? false;
         }
         internal bool IsComplete()
         {
-            return Calibrations.FirstOrDefault(c => c.Phase == PhaseCalibration.FIN)?.IsComplete() ?? false;
+            return Calibrations?.FirstOrDefault(c => c.Phase == PhaseCalibration.FIN)?.IsComplete() ?? false;
+        }
+
+        internal void AddCalibration(Calibration calibration)
+        {
+            calibration.Journee = this;
+            Calibrations.Add(calibration);
         }
         #endregion
     }
