Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
e0ca716162 |
@@ -20,34 +20,18 @@ namespace Workshop8.Data
|
|||||||
|
|
||||||
public async Task<IEnumerable<Cliente>> GetAllClientsAsync()
|
public async Task<IEnumerable<Cliente>> GetAllClientsAsync()
|
||||||
{
|
{
|
||||||
// SELECT
|
// TODO: implementar SELECT
|
||||||
var clientes = new List<Cliente>();
|
|
||||||
|
|
||||||
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<Cliente>();
|
return new List<Cliente>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddClientAsync(Cliente c)
|
public async Task AddClientAsync(Cliente c)
|
||||||
{
|
{
|
||||||
// TODO: implementar INSERT
|
// TODO: implementar INSERT
|
||||||
|
|
||||||
|
//teste
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateClientAsync(Cliente c)
|
public async Task UpdateClientAsync(Cliente c)
|
||||||
|
Reference in New Issue
Block a user