diff --git a/Database.cs b/Database.cs index 7fe6ab1..4ce3c15 100644 --- a/Database.cs +++ b/Database.cs @@ -9,17 +9,21 @@ namespace HegreHotel { public static async Task CreateDatabaseAsync() { - // Construction du chemin de la BDD dans le dossier AppData string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3"); - - // Récupération de l'instance unique du Singleton var db = SingletonConnection.GetInstance(dbPath); - // Création des tables await db.CreateTableAsync(); await db.CreateTableAsync(); await db.CreateTableAsync(); await db.CreateTableAsync(); + + var statuts = await db.Table().ToListAsync(); + if (statuts.Count == 0) + { + await db.InsertAsync(new Status { Libelle = "Disponible" }); + await db.InsertAsync(new Status { Libelle = "Occupée" }); + await db.InsertAsync(new Status { Libelle = "Indisponible" }); + } } } } \ No newline at end of file diff --git a/MainPage.xaml.cs b/MainPage.xaml.cs index 492169e..7d78e2f 100644 --- a/MainPage.xaml.cs +++ b/MainPage.xaml.cs @@ -1,5 +1,6 @@ using HegreHotel.Views; using HegreHotel.Views.Chambre; +using HegreHotel.Views.Client; using HegreHotel.Views.Reservation; using Microsoft.Maui.Controls; diff --git a/Models/Chambre.cs b/Models/Chambre.cs index bffa2ac..d3460ca 100644 --- a/Models/Chambre.cs +++ b/Models/Chambre.cs @@ -15,4 +15,6 @@ public class Chambre public decimal Tarif { get; set; } public int NbPersonne { get; set; } + + public int StatusId { get; set; } } diff --git a/Models/Reservation.cs b/Models/Reservation.cs index 352e0af..a705b67 100644 --- a/Models/Reservation.cs +++ b/Models/Reservation.cs @@ -15,4 +15,7 @@ public class Reservation public int NbPersonnes { get; set; } + public int ClientId { get; set; } + public int ChambreId { get; set; } + } diff --git a/Models/Status.cs b/Models/Status.cs index 89cc79d..61f6da4 100644 --- a/Models/Status.cs +++ b/Models/Status.cs @@ -6,7 +6,6 @@ public class Status { [PrimaryKey, AutoIncrement] public int Id { get; set; } - - [MaxLength(50), Unique] + public string? Libelle { get; set; } } diff --git a/SingletonConnection.cs b/SingletonConnection.cs index d02c533..e69aa38 100644 --- a/SingletonConnection.cs +++ b/SingletonConnection.cs @@ -6,15 +6,12 @@ namespace HegreHotel { public class SingletonConnection : SQLiteAsyncConnection { - // Instance unique de la connexion private static SingletonConnection instance; - // Constructeur privé qui appelle le constructeur parent avec le chemin de la BDD private SingletonConnection(string dbPath) : base(dbPath) { } - // Point d'accès global à l'instance public static SingletonConnection GetInstance(string dbPath) { if (instance == null) diff --git a/Views/Chambre/AjouterChambrePage.xaml.cs b/Views/Chambre/AjouterChambrePage.xaml.cs index a1676c1..85eb50e 100644 --- a/Views/Chambre/AjouterChambrePage.xaml.cs +++ b/Views/Chambre/AjouterChambrePage.xaml.cs @@ -19,7 +19,8 @@ namespace HegreHotel.Views.Chambre Nom = EntryNom.Text, Description = EntryDescription.Text, Tarif = decimal.TryParse(EntryTarif.Text, out decimal tarif) ? tarif : 0, - NbPersonne = int.TryParse(EntryNbPersonne.Text, out int nb) ? nb : 0 + NbPersonne = int.TryParse(EntryNbPersonne.Text, out int nb) ? nb : 0, + StatusId = 1 }; string dbPath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db3"); diff --git a/Views/Chambre/ChambresPage.xaml b/Views/Chambre/ChambresPage.xaml index 6fe545b..649a51d 100644 --- a/Views/Chambre/ChambresPage.xaml +++ b/Views/Chambre/ChambresPage.xaml @@ -6,35 +6,33 @@ Title="Gestion des Chambres" Appearing="ChambresPage_OnAppearing"> - + + +