Compare commits
1 Commits
ws8/rldp/l
...
ws8/gviana
Author | SHA1 | Date | |
---|---|---|---|
db37684595 |
@@ -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)
|
||||
|
Reference in New Issue
Block a user