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/ViewModel/CreateCalibrationViewModel.cs b/GES_PAC/ViewModel/CreateCalibrationViewModel.cs
index 737f027..9a0165a 100644
--- a/GES_PAC/ViewModel/CreateCalibrationViewModel.cs
+++ b/GES_PAC/ViewModel/CreateCalibrationViewModel.cs
@@ -1,5 +1,6 @@
 using GES_PAC.Model;
 using GES_PAC.View;
+using Microsoft.EntityFrameworkCore;
 using System.Collections.ObjectModel;
 using System.Windows.Input;
 
@@ -11,6 +12,7 @@ namespace GES_PAC.ViewModel
 
         #region Attributs
         public string _phaseName;
+        private ObservableCollection<TypeCalibration> _typeCalibrations;
         private TypeCalibration _selectedType;
         private double? _conc_o2;
         private double? _conc_co2;
@@ -36,19 +38,30 @@ namespace GES_PAC.ViewModel
             get => _phaseName;
             set
             {
+                if (_phaseName == value) return;
                 _phaseName = value;
                 Phase = PhaseCalibration.All.FirstOrDefault(p => p.Name == value) ?? PhaseCalibration.DEBUT;
                 OnPropertyChanged();
+                OnPhaseChanged();
             }
         }
-        public ObservableCollection<TypeCalibration> TypeCalibrations { get; }
+        public ObservableCollection<TypeCalibration> TypeCalibrations
+        {
+            get => _typeCalibrations;
+            set
+            {
+                _typeCalibrations = value;
+                OnPropertyChanged();
+            }
+        }
+
         public TypeCalibration SelectedType
         {
             get => _selectedType;
             set
             {
                 _selectedType = value;
-                IsRefBouteilleVisible = _selectedType != TypeCalibration.Air;
+                IsRefBouteilleVisible = _selectedType != TypeCalibration.AIR;
                 OnPropertyChanged();
                 OnTypeChanged();
                 ValidateForm();
@@ -173,32 +186,51 @@ namespace GES_PAC.ViewModel
         public CreateCalibrationViewModel()
         {
             CreateCalibrationCommand = new Command(async () => await CreateCalibration());
+        }
+        #endregion
 
+        #region Méthodes
+
+        public void OnPhaseChanged()
+        {
             var journeeActuelle = JourneeViewModel.Instance.GetCurrentDay();
-            var typesManquants = journeeActuelle.GetCurrentMissingCalibration();
-            var phaseCalibration = journeeActuelle.GetCurrentPhase();
+            var typesManquants = journeeActuelle.GetMissingCalibrationByPhase(Phase);
 
             TypeCalibrations = new ObservableCollection<TypeCalibration>(typesManquants);
             SelectedType = TypeCalibrations[0];
 
-            if (journeeActuelle.GetCurrentPhase() == PhaseCalibration.FIN)
-            { 
+            if (Phase == PhaseCalibration.FIN)
+            {
                 LastCalibration = journeeActuelle.GetDebutCalibration();
                 HasLastMeasure = true;
+                OnTypeChanged();
             }
         }
-        #endregion
-
-        #region Méthodes
         private async Task CreateCalibration()
         {
             if (IsBusy) return;
             IsBusy = true;
 
+            var journee = JourneeViewModel.Instance.GetCurrentDay();
             var date = DateTime.Now;
             var newCalib = new MesureCalibration(date, ConcO2 ?? 0, ConcCO2 ?? 0, ConcCH4 ?? 0, SelectedType, RefBouteille);
-            var isComplete = JourneeViewModel.Instance.GetCurrentDay().AddCalibration(newCalib, Phase);
 
+            var calibration = journee.Calibrations.FirstOrDefault(c => c.Phase == Phase);
+            if (calibration == null)
+            {
+                calibration = new Calibration(Phase, newCalib);
+                journee.AddCalibration(calibration);
+                App.Db.Calibration.Add(calibration);
+            }
+            else
+            {
+                calibration.AddMesure(newCalib);
+            }
+
+            App.Db.MesureCalibration.Add(newCalib);
+            await App.Db.SaveChangesAsync();
+
+            var isComplete = calibration.IsComplete();
             var targetView = $"{nameof(CreateCalibrationView)}?phase={PhaseName}";
             if (isComplete) {
                 targetView = Phase == PhaseCalibration.DEBUT ? nameof(SetListView) : nameof(MainView);
