inraetemplate / INRAETemplate / ViewModel / VivantViewModel.cs @ fa2aa88f
Historique | Voir | Annoter | Télécharger (3,057 ko)
1 |
using INRAETemplate.DAO; |
---|---|
2 |
using INRAETemplate.Model; |
3 |
using INRAETemplate.View; |
4 |
using INRAETemplate.ViewModel.Base; |
5 |
using System; |
6 |
using System.Collections.Generic; |
7 |
using System.Collections.ObjectModel; |
8 |
using System.Linq; |
9 |
using System.Text; |
10 |
using System.Threading.Tasks; |
11 |
using System.Windows.Input; |
12 |
|
13 |
namespace INRAETemplate.ViewModel |
14 |
{ |
15 |
public class VivantViewModel : BaseViewModel |
16 |
{ |
17 |
#region Attributs |
18 |
private int vivantId; |
19 |
private string vivantNom; |
20 |
//Pour le Picker : attributs vivants et vivantSelectionne |
21 |
private ObservableCollection<Vivant> vivants; |
22 |
private Vivant vivantSelectionne; |
23 |
#endregion |
24 |
|
25 |
#region Commandes |
26 |
public ICommand EditionCommand { get; private set; } |
27 |
#endregion |
28 |
|
29 |
#region Propriétés |
30 |
public int VivantId |
31 |
{ |
32 |
get { return vivantId; } |
33 |
set |
34 |
{ |
35 |
if (vivantId != value) |
36 |
{ |
37 |
vivantId = value; |
38 |
OnPropertyChanged(nameof(VivantId)); |
39 |
} |
40 |
} |
41 |
} |
42 |
|
43 |
public string VivantNom |
44 |
{ |
45 |
get { return vivantNom; } |
46 |
set |
47 |
{ |
48 |
if (vivantNom != value) |
49 |
{ |
50 |
vivantNom = value; |
51 |
OnPropertyChanged(nameof(VivantNom)); |
52 |
} |
53 |
} |
54 |
} |
55 |
//Pour le Picker : propriétés Vivants et VivantSelectionne |
56 |
public ObservableCollection<Vivant> Vivants |
57 |
{ |
58 |
get { return vivants; } |
59 |
set |
60 |
{ |
61 |
if (vivants != value) |
62 |
{ |
63 |
vivants = value; |
64 |
OnPropertyChanged(nameof(Vivants)); |
65 |
} |
66 |
} |
67 |
} |
68 |
|
69 |
public Vivant VivantSelectionne |
70 |
{ |
71 |
get { return vivantSelectionne; } |
72 |
set |
73 |
{ |
74 |
if (vivantSelectionne != value) |
75 |
{ |
76 |
vivantSelectionne = value; |
77 |
OnPropertyChanged(nameof(vivantSelectionne)); |
78 |
VivantId = vivantSelectionne.VivantId; |
79 |
VivantNom = vivantSelectionne.VivantNom; |
80 |
} |
81 |
} |
82 |
} |
83 |
#endregion |
84 |
|
85 |
#region Constructeurs |
86 |
public VivantViewModel() |
87 |
{ |
88 |
//Alimentation du Picker à partir de VivantDAO |
89 |
Vivants = new ObservableCollection<Vivant>(VivantDAO.GetVivants()); |
90 |
EditionCommand = new Command(async () => await Edition()); |
91 |
} |
92 |
#endregion |
93 |
|
94 |
#region Méthodes |
95 |
private async Task Edition() |
96 |
{ |
97 |
IsBusy = true; |
98 |
await Task.Delay(1000); |
99 |
IDictionary<string, object> proprietes = new Dictionary<string, object>(); |
100 |
proprietes.Add("IdVivant", VivantId); |
101 |
await Shell.Current.GoToAsync(nameof(VivantEditionView), true, proprietes); |
102 |
IsBusy = false; |
103 |
} |
104 |
#endregion |
105 |
|
106 |
} |
107 |
} |