Révision 18f910c6 GES_PAC/ViewModel/CreateDayViewModel.cs

Voir les différences:

GES_PAC/ViewModel/CreateDayViewModel.cs
7 7
{
8 8
    public class CreateDayViewModel : BaseViewModel
9 9
    {
10
        public ObservableCollection<Personne> Persons => PersonViewModel.Instance.Persons;
11 10

  
11
        #region Attributs
12 12
        private Personne _selectedPerson;
13
        private string _espece;
14
        private string _regime;
15
        private bool _isFormValid;
16
        #endregion
17

  
18
        #region Commandes
19
        public ICommand CreateDayCommand { get; }
20
        public ICommand AddPersonCommand { get; }
21
        public ICommand AddPlaceCommand { get; }
22
        #endregion
23

  
24
        #region Propriétés
25
        public ObservableCollection<Personne> Persons => PersonViewModel.Instance.Persons;
13 26
        public Personne SelectedPerson
14 27
        {
15 28
            get => _selectedPerson;
......
34 47
            }
35 48
        }
36 49

  
37
        private string _espece;
50
        
38 51
        public string Espece
39 52
        {
40 53
            get => _espece;
......
46 59
            }
47 60
        }
48 61

  
49
        private string _regime;
62
        
50 63
        public string Regime
51 64
        {
52 65
            get => _regime;
......
57 70
                ValidateForm();
58 71
            }
59 72
        }
60
        private bool _isFormValid;
73
        
61 74
        public bool IsFormValid
62 75
        {
63 76
            get => _isFormValid;
......
72 85
        public bool PersonError { get; private set; } = true;
73 86
        public bool EspeceError { get; private set; } = true;
74 87
        public bool RegimeError { get; private set; } = true;
88
        #endregion
75 89

  
76
        public ICommand ReturnCommand { get; }
77
        public ICommand CreateDayCommand { get; }
78
        public ICommand AddPersonCommand { get; }
79
        public ICommand AddPlaceCommand { get; }
80

  
81

  
90
        #region Constructeurs
82 91
        public CreateDayViewModel()
83 92
        {
84
            ReturnCommand = new Command(async () => await Return());
85 93
            CreateDayCommand = new Command(async () => await CreateDay());
86 94
            AddPersonCommand = new Command(async () => await AddPerson());
87 95
            AddPlaceCommand = new Command(async () => await AddPlace());
88 96
        }
97
        #endregion
89 98

  
90
        private async Task Return() => await Shell.Current.GoToAsync("..");
99
        #region Méthodes
91 100
        private async Task AddPerson() => await Shell.Current.GoToAsync(nameof(CreatePersonView));
92 101
        private async Task AddPlace() => await Shell.Current.GoToAsync(nameof(CreatePlaceView));
93 102
        private async Task CreateDay()
94 103
        {
104
            IsBusy = true;
95 105
            var date = DateTime.Now;
96 106
            var newDay = new Journee(date, SelectedPerson, SelectedPlace, Espece, Regime);
97 107
            JourneeViewModel.Instance.Journees.Add(newDay);
98
            await Shell.Current.GoToAsync("///Main");
108
            await Shell.Current.GoToAsync("//Main"); // A changer plus tard
109
            IsBusy = false;
99 110
        }
100 111

  
101 112
        private void ValidateForm()
......
114 125

  
115 126
            (CreateDayCommand as Command)?.ChangeCanExecute();
116 127
        }
117

  
128
        #endregion
118 129
    }
119 130
}

Formats disponibles : Unified diff