inraetemplate / INRAETemplate / ViewModel / VivantEditionViewModel.cs @ fa2aa88f
Historique | Voir | Annoter | Télécharger (1,878 ko)
1 |
using INRAETemplate.DAO; |
---|---|
2 |
using INRAETemplate.Model; |
3 |
using INRAETemplate.ViewModel.Base; |
4 |
using System; |
5 |
using System.Collections.Generic; |
6 |
using System.Linq; |
7 |
using System.Text; |
8 |
using System.Threading.Tasks; |
9 |
using System.Windows.Input; |
10 |
|
11 |
namespace INRAETemplate.ViewModel |
12 |
{ |
13 |
[QueryProperty(nameof(VivantId), "IdVivant")] |
14 |
public class VivantEditionViewModel : BaseViewModel |
15 |
{ |
16 |
#region Attributs |
17 |
private int vivantId; |
18 |
private string vivantNom; |
19 |
private Vivant vivantDeLaPage; |
20 |
#endregion |
21 |
|
22 |
#region Commandes |
23 |
public ICommand EnregistrerCommand { get; private set; } |
24 |
#endregion |
25 |
|
26 |
#region Propriétés |
27 |
public int VivantId |
28 |
{ |
29 |
get { return vivantId; } |
30 |
set |
31 |
{ |
32 |
if (value != 0 && vivantId != value) |
33 |
{ |
34 |
vivantId = value; |
35 |
OnPropertyChanged(nameof(VivantId)); |
36 |
vivantDeLaPage = VivantDAO.GetVivantById(VivantId); |
37 |
VivantNom = vivantDeLaPage.VivantNom; |
38 |
} |
39 |
} |
40 |
} |
41 |
public string VivantNom |
42 |
{ |
43 |
get { return vivantNom; } |
44 |
set |
45 |
{ |
46 |
if (vivantNom != value) |
47 |
{ |
48 |
vivantNom = value; |
49 |
OnPropertyChanged(nameof(VivantNom)); |
50 |
} |
51 |
} |
52 |
} |
53 |
#endregion |
54 |
|
55 |
#region Constructeurs |
56 |
public VivantEditionViewModel() |
57 |
{ |
58 |
EnregistrerCommand = new Command(async () => await Enregistrer()); |
59 |
} |
60 |
#endregion |
61 |
|
62 |
#region Méthodes |
63 |
public async Task Enregistrer() |
64 |
{ |
65 |
IsBusy = true; |
66 |
await VivantDAO.Save(vivantDeLaPage); |
67 |
IsBusy = false; |
68 |
} |
69 |
#endregion |
70 |
|
71 |
} |
72 |
} |