Révision 18f910c6 GES_PAC/ViewModel/CreatePersonViewModel.cs
GES_PAC/ViewModel/CreatePersonViewModel.cs | ||
---|---|---|
5 | 5 |
{ |
6 | 6 |
public class CreatePersonViewModel : BaseViewModel |
7 | 7 |
{ |
8 |
#region Attributs |
|
8 | 9 |
private string _nom; |
10 |
private string _prenom; |
|
11 |
private string _email; |
|
12 |
private bool _isFormValid; |
|
13 |
#endregion |
|
14 |
|
|
15 |
#region Commandes |
|
16 |
public ICommand CreatePersonCommand { get; } |
|
17 |
#endregion |
|
18 |
|
|
19 |
#region Propriétés |
|
9 | 20 |
public string Nom |
10 | 21 |
{ |
11 | 22 |
get => _nom; |
... | ... | |
16 | 27 |
ValidateForm(); |
17 | 28 |
} |
18 | 29 |
} |
19 |
private string _prenom; |
|
30 |
|
|
20 | 31 |
public string Prenom |
21 | 32 |
{ |
22 | 33 |
get => _prenom; |
... | ... | |
27 | 38 |
ValidateForm(); |
28 | 39 |
} |
29 | 40 |
} |
30 |
private string _email; |
|
41 |
|
|
31 | 42 |
public string Email |
32 | 43 |
{ |
33 | 44 |
get => _email; |
... | ... | |
38 | 49 |
ValidateForm(); |
39 | 50 |
} |
40 | 51 |
} |
41 |
private bool _isFormValid; |
|
52 |
|
|
42 | 53 |
public bool IsFormValid |
43 | 54 |
{ |
44 | 55 |
get => _isFormValid; |
... | ... | |
52 | 63 |
public bool NomError { get; private set; } = true; |
53 | 64 |
public bool PrenomError { get; private set; } = true; |
54 | 65 |
public bool EmailError { get; private set; } = true; |
66 |
#endregion |
|
55 | 67 |
|
56 |
|
|
57 |
public ICommand ReturnCommand { get; } |
|
58 |
public ICommand CreatePersonCommand { get; } |
|
59 |
|
|
68 |
#region Constructeurs |
|
60 | 69 |
public CreatePersonViewModel() |
61 | 70 |
{ |
62 |
ReturnCommand = new Command(async () => await Return()); |
|
63 | 71 |
CreatePersonCommand = new Command(async () => await CreatePerson()); |
64 | 72 |
} |
65 |
private async Task Return() |
|
66 |
{ |
|
67 |
await Shell.Current.GoToAsync(".."); |
|
68 |
} |
|
73 |
#endregion |
|
74 |
|
|
75 |
#region Méthodes |
|
69 | 76 |
private async Task CreatePerson() |
70 | 77 |
{ |
71 | 78 |
var newTechnician = new Personne(Nom, Prenom, Email); |
72 | 79 |
PersonViewModel.Instance.Persons.Add(newTechnician); |
73 |
await Shell.Current.GoToAsync("..");
|
|
80 |
await Shell.Current.GoToAsync("//Main");
|
|
74 | 81 |
} |
75 | 82 |
|
76 | 83 |
private void ValidateForm() |
... | ... | |
87 | 94 |
|
88 | 95 |
(CreatePersonCommand as Command)?.ChangeCanExecute(); |
89 | 96 |
} |
97 |
#endregion |
|
90 | 98 |
} |
91 | 99 |
} |
Formats disponibles : Unified diff