Statistiques
| Branche: | Révision:

root / GES_PAC / ViewModel / MainViewModel.cs @ 957b1f34

Historique | Voir | Annoter | Télécharger (1,753 ko)

1 12ddf7ef lbihannic
using GES_PAC.Model;
2 18f910c6 Lucas Bihannic
using GES_PAC.Services;
3 65ad7e66 Lucas Bihannic
using GES_PAC.View;
4
5
namespace GES_PAC.ViewModel
6
{
7
    public class MainViewModel : BaseViewModel
8
    {
9 18f910c6 Lucas Bihannic
        #region Services
10
        private readonly ConnexionService connService;
11
        #endregion
12
13
        #region Commandes
14 65ad7e66 Lucas Bihannic
        public Command GoToCreateDayCommand { get; }
15 18f910c6 Lucas Bihannic
        #endregion
16
17
        #region Constructeur
18
        public MainViewModel(ConnexionService connService)
19 65ad7e66 Lucas Bihannic
        {
20 12ddf7ef lbihannic
            //ONLY FOR TESTS
21 957b1f34 lbihannic
            var date = DateTime.Now;
22
            var newDay = new Journee(date, PersonViewModel.Instance.Persons[0], PlaceViewModel.Instance.Places[0], "");
23
            newDay.AddSet(new Serie(date, date, 25, 25, 25));
24
            newDay.AddCalibration(new MesureCalibration(date, 50, 40, 500, TypeCalibration.Air, ""), PhaseCalibration.Debut);
25
            newDay.AddCalibration(new MesureCalibration(date, 0, 0, 1000000, TypeCalibration.Methane, "dazdazd"), PhaseCalibration.Debut);
26
            newDay.AddCalibration(new MesureCalibration(date, 30, 30, 3000, TypeCalibration.Melange, "deqsfsdf"), PhaseCalibration.Debut);
27
            newDay.GetCurrentSet().AddSerieAnimal(new SerieAnimal(1, 500, date, ""));
28
            newDay.GetCurrentSet().AddMeasure(new Mesure(date, 50, 50, 50), 1, false);
29
            JourneeViewModel.Instance.Journees.Add(newDay);
30 12ddf7ef lbihannic
            //ONLY FOR TESTS
31
32 18f910c6 Lucas Bihannic
            this.connService = connService;
33 65ad7e66 Lucas Bihannic
            GoToCreateDayCommand = new Command(async () => await GoToCreateDayPage());
34
        }
35 18f910c6 Lucas Bihannic
        #endregion
36 65ad7e66 Lucas Bihannic
37 18f910c6 Lucas Bihannic
        #region Méthodes
38 65ad7e66 Lucas Bihannic
        private async Task GoToCreateDayPage()
39
        {
40 1019554c lbihannic
            if (IsBusy) return;
41 18f910c6 Lucas Bihannic
            IsBusy = true;
42 65ad7e66 Lucas Bihannic
            await Shell.Current.GoToAsync(nameof(CreateDayView));
43 18f910c6 Lucas Bihannic
            IsBusy = false;
44 65ad7e66 Lucas Bihannic
        }
45 18f910c6 Lucas Bihannic
        #endregion
46 65ad7e66 Lucas Bihannic
    }
47
}