Update Data/SqliteClientRepository.cs

This commit is contained in:
2025-07-30 18:46:00 +00:00
parent 890bdf831b
commit db37684595

View File

@@ -20,8 +20,28 @@ namespace Workshop8.Data
public async Task<IEnumerable<Cliente>> GetAllClientsAsync()
{
var clientes = new List<Cliente>();
// TODO: implementar SELECT
return new List<Cliente>();
await using var conn = new SqliteConnection("Data Source=database.sqlite;");
await conn.OpenAsync();
var cmd = conn.CreateCommand();
cmd.CommandText = "SELECT Nome, Email, CriadoEm FROM Clientes;";
await using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
var p = new Cliente
{
Id = reader.GetInt32(0),
Email = reader.GetString(1),
CriadoEm = reader.GetDateTime(2)
};
clientes.Add(p);
}
return clientes;
}
public async Task AddClientAsync(Cliente c)