Statistiques
| Branche: | Révision:

root / GES_PAC / ViewModel / SetListViewModel.cs @ 42456640

Historique | Voir | Annoter | Télécharger (2,245 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 acb5dd8c lbihannic
        public string _lastSetText;
12 4e39035b lbihannic
        #endregion
13
14
        #region Propriétés
15
        public bool HasLastSet
16
        {
17
            get => _hasLastSet;
18
            set
19
            {
20
                SetProperty(ref _hasLastSet, value);
21
                OnPropertyChanged();
22
            }
23
        }
24 acb5dd8c lbihannic
        public string LastSetText
25
        {
26
            get => _lastSetText;
27
            set
28
            {
29
                SetProperty(ref _lastSetText, value);
30
                OnPropertyChanged();
31
            }
32
        }
33 09d4a0de lbihannic
        #endregion
34
35
        #region Commandes
36
        public ICommand GoToCreateSetCommand { get; }
37 4e39035b lbihannic
        public ICommand GoToLastSetCommand { get; }
38 957b1f34 lbihannic
        public ICommand GoToEndDayCommand { get; }
39 09d4a0de lbihannic
        #endregion
40
41
        #region Constructeur
42
        public SetListViewModel()
43
        {
44
            GoToCreateSetCommand = new Command(async () => await GoToCreateSetPage());
45 4e39035b lbihannic
            GoToLastSetCommand = new Command(async () => await GoToLastSetPage());
46 957b1f34 lbihannic
            GoToEndDayCommand = new Command(async () => await GoToEndDayPage());
47 4e39035b lbihannic
48 acb5dd8c lbihannic
            GetLastSet();
49 09d4a0de lbihannic
        }
50
        #endregion
51
52
        #region Méthodes
53
        private async Task GoToCreateSetPage()
54
        {
55 1019554c lbihannic
            if (IsBusy) return;
56 09d4a0de lbihannic
            IsBusy = true;
57
            await Shell.Current.GoToAsync(nameof(CreateSetView));
58
            IsBusy = false;
59
        }
60 4e39035b lbihannic
61
        private async Task GoToLastSetPage()
62
        {
63
            if (IsBusy) return;
64
            IsBusy = true;
65 42456640 lbihannic
            await Shell.Current.Navigation.PopToRootAsync();
66 4e39035b lbihannic
            IsBusy = false;
67
        }
68 957b1f34 lbihannic
        private async Task GoToEndDayPage()
69
        {
70
            if (IsBusy) return;
71
            IsBusy = true;
72
            await Shell.Current.GoToAsync(nameof(EndDayView));
73
            IsBusy = false;
74
        }
75 acb5dd8c lbihannic
        public void GetLastSet()
76
        {
77
            HasLastSet = JourneeViewModel.Instance.GetCurrentDay()?.HasAnySet() ?? false;
78
            LastSetText = HasLastSet ? "Une série en cours, la reprendre ?" : "Aucune série trouvée, en créer une ?";
79
        }
80 09d4a0de lbihannic
        #endregion
81
    }
82
}