From 0bef889ffd7db0fbf5f7aaa7b02e7ddc663de0aa Mon Sep 17 00:00:00 2001 From: usuario Date: Wed, 30 Jul 2025 18:04:46 +0000 Subject: [PATCH] add: Listagem de clientes --- Data/SqliteClientRepository.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Data/SqliteClientRepository.cs b/Data/SqliteClientRepository.cs index 2aab76a..adf5eb7 100644 --- a/Data/SqliteClientRepository.cs +++ b/Data/SqliteClientRepository.cs @@ -20,7 +20,28 @@ namespace Workshop8.Data public async Task> GetAllClientsAsync() { - // TODO: implementar SELECT + // SELECT + var clientes = new List(); + + await using var conn = new SqliteConnection(_connectionString); + await conn.OpenAsync(); + + var cmd = conn.CreateCommand(); + cmd.CommandText = "SELECT id, nome, email, CriadoEm FROM Clientes;"; + + await using var reader = await cmd.ExecuteReaderAsync(); + while (await reader.ReadAsync()) + { + var c = new Cliente + { + Id = reader.GetInt32(0), + Nome = reader.GetString(1), + Email = reader.GetString(2), + CriadoEm = reader.GetDateTime(3) + }; + clientes.Add(c); + } + return clientes; return new List(); }