Statistiques
| Branche: | Révision:

root / GES_PAC / ViewModel / PlaceViewModel.cs @ 6f451cc1

Historique | Voir | Annoter | Télécharger (832 octets)

1 65ad7e66 Lucas Bihannic
using GES_PAC.Model;
2 6f451cc1 lbihannic
using Microsoft.EntityFrameworkCore;
3 65ad7e66 Lucas Bihannic
using System.Collections.ObjectModel;
4
5
namespace GES_PAC.ViewModel
6
{
7
    public class PlaceViewModel
8
    {
9 18f910c6 Lucas Bihannic
        #region Attributs
10 65ad7e66 Lucas Bihannic
        private static PlaceViewModel _instance;
11 18f910c6 Lucas Bihannic
        #endregion
12 65ad7e66 Lucas Bihannic
13 18f910c6 Lucas Bihannic
        #region Propriétés
14
        public ObservableCollection<Lieu> Places { get; set; } = new();
15
        public static PlaceViewModel Instance => _instance ??= new PlaceViewModel();
16
        #endregion
17
        
18
        #region Constructeur
19 5d673ce0 Lucas Bihannic
        private PlaceViewModel() {
20 6f451cc1 lbihannic
            _ = InitAsync();
21
        }
22
        #endregion
23
        #region Méthodes
24
        public async Task InitAsync()
25
        {
26
            var lieux = await App.Db.Lieu.ToListAsync();
27
            foreach (var l in lieux)
28
                Places.Add(l);
29 5d673ce0 Lucas Bihannic
        }
30 18f910c6 Lucas Bihannic
        #endregion
31 65ad7e66 Lucas Bihannic
    }
32
}