Compare commits
2 Commits
main
...
ws8/arthur
Author | SHA1 | Date | |
---|---|---|---|
eb6f560213 | |||
ca6b7d311c |
@@ -20,8 +20,32 @@ namespace Workshop8.Data
|
||||
|
||||
public async Task<IEnumerable<Cliente>> GetAllClientsAsync()
|
||||
{
|
||||
// TODO: implementar SELECT
|
||||
return new List<Cliente>();
|
||||
var clientes = new List<Cliente>();
|
||||
|
||||
await using (var connection = new SqliteConnection(_connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await using (var cmd = connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = @"SELECT Id, Nome, Email, CriadoEm
|
||||
FROM Clientes
|
||||
ORDER BY Id;";
|
||||
await using (var reader = await cmd.ExecuteReaderAsync())
|
||||
{
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
clientes.Add(new Cliente
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Nome = reader.GetString(1),
|
||||
Email = reader.GetString(2),
|
||||
CriadoEm = reader.GetDateTime(3)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return clientes;
|
||||
}
|
||||
|
||||
public async Task AddClientAsync(Cliente c)
|
||||
|
@@ -3,8 +3,9 @@
|
||||
@{
|
||||
ViewData["Title"] = "Clientes";
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center my-3">
|
||||
<h2>Clientes</h2>
|
||||
<h3>Clientes</h3>
|
||||
<button class="btn btn-primary" type="button" id="createClientBtn">Adicionar Cliente</button>
|
||||
</div>
|
||||
<table class="table table-striped">
|
||||
|
Reference in New Issue
Block a user