Statistiques
| Branche: | Révision:

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

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

1 09d4a0de lbihannic
using System.Windows.Input;
2
using GES_PAC.View;
3
4
5
namespace GES_PAC.ViewModel
6
{
7
    public class SetListViewModel : BaseViewModel
8
    {
9 4e39035b lbihannic
        #region Attributs
10
        private bool _hasLastSet = false;
11
        #endregion
12
13
        #region Propriétés
14
        public bool HasLastSet
15
        {
16
            get => _hasLastSet;
17
            set
18
            {
19
                SetProperty(ref _hasLastSet, value);
20
                OnPropertyChanged();
21
            }
22
        }
23
24
        public string LastSetText => HasLastSet ? "Série existante. La reprendre ?" : "Aucune série trouvée";
25 09d4a0de lbihannic
        #endregion
26
27
        #region Commandes
28
        public ICommand GoToCreateSetCommand { get; }
29 4e39035b lbihannic
        public ICommand GoToLastSetCommand { get; }
30 957b1f34 lbihannic
        public ICommand GoToEndDayCommand { get; }
31 09d4a0de lbihannic
        #endregion
32
33
        #region Constructeur
34
        public SetListViewModel()
35
        {
36
            GoToCreateSetCommand = new Command(async () => await GoToCreateSetPage());
37 4e39035b lbihannic
            GoToLastSetCommand = new Command(async () => await GoToLastSetPage());
38 957b1f34 lbihannic
            GoToEndDayCommand = new Command(async () => await GoToEndDayPage());
39 4e39035b lbihannic
40
            HasLastSet = JourneeViewModel.Instance.GetCurrentDay().HasAnySet();
41 09d4a0de lbihannic
        }
42
        #endregion
43
44
        #region Méthodes
45
        private async Task GoToCreateSetPage()
46
        {
47 1019554c lbihannic
            if (IsBusy) return;
48 09d4a0de lbihannic
            IsBusy = true;
49
            await Shell.Current.GoToAsync(nameof(CreateSetView));
50
            IsBusy = false;
51
        }
52 4e39035b lbihannic
53
        private async Task GoToLastSetPage()
54
        {
55
            if (IsBusy) return;
56
            IsBusy = true;
57
            await Shell.Current.GoToAsync(nameof(ChambersView));
58
            IsBusy = false;
59
        }
60 957b1f34 lbihannic
        private async Task GoToEndDayPage()
61
        {
62
            if (IsBusy) return;
63
            IsBusy = true;
64
            await Shell.Current.GoToAsync(nameof(EndDayView));
65
            IsBusy = false;
66
        }
67 09d4a0de lbihannic
        #endregion
68
    }
69
}