Statistiques
| Branche: | Révision:

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

Historique | Voir | Annoter | Télécharger (847 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 PersonViewModel
8
    {
9 18f910c6 Lucas Bihannic
        #region Attributs
10 65ad7e66 Lucas Bihannic
        private static PersonViewModel _instance;
11 18f910c6 Lucas Bihannic
        #endregion
12
13
        #region Propriétés
14
        public ObservableCollection<Personne> Persons { get; set; } = new();
15 65ad7e66 Lucas Bihannic
        public static PersonViewModel Instance => _instance ??= new PersonViewModel();
16 18f910c6 Lucas Bihannic
        #endregion
17 65ad7e66 Lucas Bihannic
18 18f910c6 Lucas Bihannic
        #region Constructeur
19 5d673ce0 Lucas Bihannic
        private PersonViewModel() {
20 6f451cc1 lbihannic
            _ = InitAsync();
21
        }
22
        #endregion
23
        #region Méthodes
24
        public async Task InitAsync()
25
        {
26
            var personnes = await App.Db.Personne.ToListAsync();
27
            foreach (var p in personnes)
28
                Persons.Add(p);
29 5d673ce0 Lucas Bihannic
        }
30 18f910c6 Lucas Bihannic
        #endregion
31 65ad7e66 Lucas Bihannic
    }
32
}