Compare commits
1 Commits
ws8/arthur
...
ws8/gviana
Author | SHA1 | Date | |
---|---|---|---|
db37684595 |
@@ -20,31 +20,27 @@ namespace Workshop8.Data
|
||||
|
||||
public async Task<IEnumerable<Cliente>> GetAllClientsAsync()
|
||||
{
|
||||
var clientes = new List<Cliente>();
|
||||
var clientes = new List<Cliente>();
|
||||
// TODO: implementar SELECT
|
||||
await using var conn = new SqliteConnection("Data Source=database.sqlite;");
|
||||
await conn.OpenAsync();
|
||||
|
||||
await using (var connection = new SqliteConnection(_connectionString))
|
||||
var cmd = conn.CreateCommand();
|
||||
cmd.CommandText = "SELECT Nome, Email, CriadoEm FROM Clientes;";
|
||||
|
||||
await using var reader = await cmd.ExecuteReaderAsync();
|
||||
while (await reader.ReadAsync())
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await using (var cmd = connection.CreateCommand())
|
||||
var p = new Cliente
|
||||
{
|
||||
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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Id = reader.GetInt32(0),
|
||||
Email = reader.GetString(1),
|
||||
CriadoEm = reader.GetDateTime(2)
|
||||
};
|
||||
clientes.Add(p);
|
||||
}
|
||||
|
||||
|
||||
return clientes;
|
||||
}
|
||||
|
||||
|
@@ -3,9 +3,8 @@
|
||||
@{
|
||||
ViewData["Title"] = "Clientes";
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center my-3">
|
||||
<h3>Clientes</h3>
|
||||
<h2>Clientes</h2>
|
||||
<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