commit acb5dd8c3945b6c92c01cba5ad1c924ca7b63e5c
Author: lbihannic <lucas.bihannic@inrae.fr>
Date:   Wed Apr 9 09:28:02 2025 +0200

    add resume day function

diff --git a/GES_PAC/ViewModel/MainViewModel.cs b/GES_PAC/ViewModel/MainViewModel.cs
index d4b0ad8..2f03710 100644
--- a/GES_PAC/ViewModel/MainViewModel.cs
+++ b/GES_PAC/ViewModel/MainViewModel.cs
@@ -1,40 +1,90 @@
 using GES_PAC.Model;
 using GES_PAC.Services;
 using GES_PAC.View;
+using System.Windows.Input;
 
 namespace GES_PAC.ViewModel
 {
-    public class MainViewModel : BaseViewModel
+    public class MainViewModel : BaseViewModel 
     {
+        #region Attributs
+        private bool _hasLastDay = false;
+        private Journee _currentDay;
+        private string _currentDayText;
+        #endregion
+
         #region Services
         private readonly ConnexionService connService;
         #endregion
 
         #region Commandes
-        public Command GoToCreateDayCommand { get; }
+        public ICommand GoToCreateDayCommand { get; }
+        public ICommand ResumeDayCommand { get; }
+        #endregion
+
+        #region Propriétés
+        public bool HasLastDay
+        {
+            get => _hasLastDay;
+            set
+            {
+                SetProperty(ref _hasLastDay, value);
+                OnPropertyChanged();
+            }
+        }
+        public Journee CurrentDay
+        {
+            get => _currentDay;
+            set
+            {
+                SetProperty(ref _currentDay, value);
+                OnPropertyChanged();
+            }
+        }
+        public string CurrentDayText
+        {
+            get => _currentDayText;
+            set
+            {
+                SetProperty(ref _currentDayText, value);
+                OnPropertyChanged();
+            }
+        }
         #endregion
 
         #region Constructeur
         public MainViewModel(ConnexionService connService)
         {
             //ONLY FOR TESTS
-            var date = DateTime.Now;
-            var newDay = new Journee(date, PersonViewModel.Instance.Persons[0], PlaceViewModel.Instance.Places[0], "");
-            newDay.AddSet(new Serie(date, date, 25, 25, 25));
-            newDay.AddCalibration(new MesureCalibration(date, 50, 40, 500, TypeCalibration.Air, ""), PhaseCalibration.Debut);
-            newDay.AddCalibration(new MesureCalibration(date, 0, 0, 1000000, TypeCalibration.Methane, "dazdazd"), PhaseCalibration.Debut);
-            newDay.AddCalibration(new MesureCalibration(date, 30, 30, 3000, TypeCalibration.Melange, "deqsfsdf"), PhaseCalibration.Debut);
-            newDay.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
-            newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false);
-            JourneeViewModel.Instance.Journees.Add(newDay);
+            //var date = DateTime.Now;
+            //var newDay = new Journee(date, PersonViewModel.Instance.Persons[0], PlaceViewModel.Instance.Places[0], "");
+            //newDay.AddSet(new Serie(date, date, 25, 25, 25));
+            //newDay.AddCalibration(new MesureCalibration(date, 50, 40, 500, TypeCalibration.Air, ""), PhaseCalibration.Debut);
+            //newDay.AddCalibration(new MesureCalibration(date, 0, 0, 1000000, TypeCalibration.Methane, "dazdazd"), PhaseCalibration.Debut);
+            //newDay.AddCalibration(new MesureCalibration(date, 30, 30, 3000, TypeCalibration.Melange, "deqsfsdf"), PhaseCalibration.Debut);
+            //newDay.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
+            //newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false);
+            //JourneeViewModel.Instance.Journees.Add(newDay);
             //ONLY FOR TESTS
 
-            this.connService = connService;
             GoToCreateDayCommand = new Command(async () => await GoToCreateDayPage());
+            ResumeDayCommand = new Command(async () => await ResumeDay());
+
+            this.connService = connService;
+
+            GetLastDay();
         }
         #endregion
 
         #region Méthodes
+        
+        public void GetLastDay()
+        {
+            CurrentDay = JourneeViewModel.Instance.GetCurrentDay();
+            HasLastDay = !CurrentDay?.IsComplete() ?? false;
+            CurrentDayText = HasLastDay ? "Une journée en cours, la reprendre ?" : "Aucune journée trouvée, en créer une ?";
+
+        }
         private async Task GoToCreateDayPage()
         {
             if (IsBusy) return;
@@ -42,6 +92,20 @@ namespace GES_PAC.ViewModel
             await Shell.Current.GoToAsync(nameof(CreateDayView));
             IsBusy = false;
         }
+
+        private async Task ResumeDay()
+        {
+            if (IsBusy) return;
+            IsBusy = true;
+
+            CurrentDay = JourneeViewModel.Instance.GetCurrentDay();
+            var targetView = nameof(CreateCalibrationView);
+            if (CurrentDay.IsCalibrationComplete(PhaseCalibration.Debut))
+                targetView = nameof(SetListView);
+
+            await Shell.Current.GoToAsync(targetView);
+            IsBusy = false;
+        }
         #endregion
     }
 }
