27 lines
720 B
C#
27 lines
720 B
C#
|
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;
|
||
|
}
|
||
|
}
|