HegreHotel/Database.cs

27 lines
720 B
C#
Raw Permalink Normal View History

2025-01-16 17:50:56 +01:00
using HegreHotel.Models;
using SQLite;
namespace HegreHotel;
public class Database
{
private static SQLiteAsyncConnection _database;
public static async Task<SQLiteAsyncConnection> GetConnection()
{
if (_database == null)
{
var databasePath = Path.Combine(FileSystem.AppDataDirectory, "HegreHotel.db");
_database = new SQLiteAsyncConnection(databasePath);
// Créer les tables
await _database.CreateTableAsync<Client>();
await _database.CreateTableAsync<Chambre>();
await _database.CreateTableAsync<Reservation>();
await _database.CreateTableAsync<Status>();
}
return _database;
}
}