Révision 3fef487c GES_PAC/ViewModel/ExportDataViewModel.cs
GES_PAC/ViewModel/ExportDataViewModel.cs | ||
---|---|---|
40 | 40 |
#region Commandes |
41 | 41 |
public ICommand ExportJSONCommand { get; } |
42 | 42 |
public ICommand ExportCSVCommand { get; } |
43 |
public ICommand ClearDataCommand { get; } |
|
43 | 44 |
#endregion |
44 | 45 |
|
45 | 46 |
#region Constructeur |
... | ... | |
47 | 48 |
{ |
48 | 49 |
ExportJSONCommand = new Command(ExportJSON); |
49 | 50 |
ExportCSVCommand = new Command(ExportCSV); |
51 |
ClearDataCommand = new Command(ClearData); |
|
50 | 52 |
|
51 | 53 |
DayList = JourneeViewModel.Instance?.Journees ?? null; |
52 | 54 |
HasData = DayList != null && DayList.Count > 0; |
... | ... | |
86 | 88 |
#endif |
87 | 89 |
} |
88 | 90 |
|
91 |
private async void ClearData() |
|
92 |
{ |
|
93 |
if (IsBusy) return; |
|
94 |
IsBusy = true; |
|
95 |
App.Db.MesureCalibration.RemoveRange(App.Db.MesureCalibration); |
|
96 |
App.Db.Calibration.RemoveRange(App.Db.Calibration); |
|
97 |
App.Db.Mesure.RemoveRange(App.Db.Mesure); |
|
98 |
App.Db.Comportement.RemoveRange(App.Db.Comportement); |
|
99 |
App.Db.SerieAnimal.RemoveRange(App.Db.SerieAnimal); |
|
100 |
App.Db.Serie.RemoveRange(App.Db.Serie); |
|
101 |
App.Db.Journee.RemoveRange(App.Db.Journee); |
|
102 |
App.Db.Personne.RemoveRange(App.Db.Personne); |
|
103 |
App.Db.Lieu.RemoveRange(App.Db.Lieu); |
|
104 |
|
|
105 |
var place = new Lieu("Elevage Langlade", "INRAE", "Mouton"); |
|
106 |
var person = new Personne("Bond", "James", "jamesbond@inrae.fr"); |
|
107 |
App.Db.Personne.Add(person); |
|
108 |
App.Db.Lieu.Add(place); |
|
109 |
|
|
110 |
await App.Db.SaveChangesAsync(); |
|
111 |
IsBusy = false; |
|
112 |
} |
|
113 |
|
|
89 | 114 |
#endregion |
90 | 115 |
} |
91 | 116 |
} |
Formats disponibles : Unified diff