diff --git a/Database.cs b/Database.cs new file mode 100644 index 0000000..d37bc3a --- /dev/null +++ b/Database.cs @@ -0,0 +1,26 @@ +using HegreHotel.Models; +using SQLite; + +namespace HegreHotel; + +public class Database +{ + private static SQLiteAsyncConnection _database; + + public static async Task GetConnection() + { + if (_database == null) + { + var databasePath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db"); + _database = new SQLiteAsyncConnection(databasePath); + + // Créer les tables + await _database.CreateTableAsync(); + await _database.CreateTableAsync(); + await _database.CreateTableAsync(); + await _database.CreateTableAsync(); + } + + return _database; + } +} diff --git a/HegreHotel.csproj b/HegreHotel.csproj index c50628a..cf89031 100644 --- a/HegreHotel.csproj +++ b/HegreHotel.csproj @@ -57,9 +57,13 @@ + + + + diff --git a/Models/Chambre.cs b/Models/Chambre.cs new file mode 100644 index 0000000..94f8b89 --- /dev/null +++ b/Models/Chambre.cs @@ -0,0 +1,18 @@ +namespace HegreHotel.Models; + +using SQLite; + +public class Chambre +{ + [PrimaryKey, AutoIncrement] + public int Id { get; set; } + + [MaxLength(50)] + public string? Nom { get; set; } + + public string? Description { get; set; } + + public decimal Tarif { get; set; } + + public int NombrePersonnes { get; set; } +} diff --git a/Models/Client.cs b/Models/Client.cs new file mode 100644 index 0000000..c4c343a --- /dev/null +++ b/Models/Client.cs @@ -0,0 +1,21 @@ +namespace HegreHotel.Models; + +using SQLite; + +public class Client +{ + [PrimaryKey, AutoIncrement] + public int Id { get; set; } + + [MaxLength(100)] + public string? Nom { get; set; } + + [MaxLength(100)] + public string? Prenom { get; set; } + + [MaxLength(150), Unique] + public string? Email { get; set; } + + [MaxLength(15), Unique] + public string? Telephone { get; set; } +} \ No newline at end of file diff --git a/Models/Reservation.cs b/Models/Reservation.cs new file mode 100644 index 0000000..444b0ba --- /dev/null +++ b/Models/Reservation.cs @@ -0,0 +1,29 @@ +namespace HegreHotel.Models; + +using SQLite; + +public class Reservation +{ + [PrimaryKey, AutoIncrement] + public int Id { get; set; } + + public DateTime DateDebut { get; set; } + + public DateTime DateFin { get; set; } + + public string? Demandes { get; set; } + + // Navigation properties (ignorées dans SQLite) + + [Indexed] + public int ClientId { get; set; } + + [Indexed] + public int ChambreId { get; set; } + + [Ignore] + public Client Client { get; set; } + + [Ignore] + public Chambre Chambre { get; set; } +} diff --git a/Models/Status.cs b/Models/Status.cs new file mode 100644 index 0000000..89cc79d --- /dev/null +++ b/Models/Status.cs @@ -0,0 +1,12 @@ +namespace HegreHotel.Models; + +using SQLite; + +public class Status +{ + [PrimaryKey, AutoIncrement] + public int Id { get; set; } + + [MaxLength(50), Unique] + public string? Libelle { get; set; } +} diff --git a/Services/ClientService.cs b/Services/ClientService.cs new file mode 100644 index 0000000..8df7f8b --- /dev/null +++ b/Services/ClientService.cs @@ -0,0 +1,36 @@ +using SQLite; +using System.Collections.Generic; +using System.Threading.Tasks; +using HegreHotel; +using HegreHotel.Models; + +public class ClientService +{ + // Ajouter un client + public static async Task AjouterClient(Client client) + { + var db = await Database.GetConnection(); + await db.InsertAsync(client); + } + + // Récupérer tous les clients + public static async Task> GetClientsAsync() + { + var db = await Database.GetConnection(); + return await db.Table().ToListAsync(); + } + + // Modifier un client + public static async Task ModifierClient(Client client) + { + var db = await Database.GetConnection(); + await db.UpdateAsync(client); + } + + // Supprimer un client + public static async Task SupprimerClient(Client client) + { + var db = await Database.GetConnection(); + await db.DeleteAsync(client); + } +} \ No newline at end of file diff --git a/Views/ClientsPage.xaml b/Views/ClientsPage.xaml new file mode 100644 index 0000000..08938cb --- /dev/null +++ b/Views/ClientsPage.xaml @@ -0,0 +1,18 @@ + + + + + +