HegreHotel/Services/ClientService.cs

36 lines
920 B
C#

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<List<Client>> GetClientsAsync()
{
var db = await Database.GetConnection();
return await db.Table<Client>().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);
}
}