|
|
|
@ -127,14 +127,66 @@ namespace WF_WebAdmin.Service
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<int> getNbQuote()
|
|
|
|
|
public async Task<int> getNbQuote()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
using var con = new NpgsqlConnection(connectionString);
|
|
|
|
|
await con.OpenAsync();
|
|
|
|
|
|
|
|
|
|
// SQL pour compter le nombre total de citations
|
|
|
|
|
var sql = "SELECT COUNT(*) FROM quote";
|
|
|
|
|
|
|
|
|
|
using var cmd = new NpgsqlCommand(sql, con);
|
|
|
|
|
|
|
|
|
|
// Exécution de la commande et récupération du résultat
|
|
|
|
|
var result = await cmd.ExecuteScalarAsync();
|
|
|
|
|
|
|
|
|
|
// Convertir le résultat en entier (si le résultat est null, renvoyer 0)
|
|
|
|
|
return result != DBNull.Value ? Convert.ToInt32(result) : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<Quote> getOnequote(int id)
|
|
|
|
|
public async Task<Quote> getOnequote(int id)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
using var con = new NpgsqlConnection(connectionString);
|
|
|
|
|
await con.OpenAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sql = @"
|
|
|
|
|
SELECT
|
|
|
|
|
id_quote AS Id,
|
|
|
|
|
content AS Content,
|
|
|
|
|
likes AS ""Like"",
|
|
|
|
|
langue AS Langue,
|
|
|
|
|
'' AS Charac,
|
|
|
|
|
'' AS ImgPath,
|
|
|
|
|
'' AS TitleSrc,
|
|
|
|
|
now() AS DateSrc,
|
|
|
|
|
'' AS UserProposition
|
|
|
|
|
FROM quote
|
|
|
|
|
WHERE id_quote = @Id
|
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
using var cmd = new NpgsqlCommand(sql, con);
|
|
|
|
|
cmd.Parameters.AddWithValue("@Id", id);
|
|
|
|
|
|
|
|
|
|
using var reader = await cmd.ExecuteReaderAsync();
|
|
|
|
|
|
|
|
|
|
if (await reader.ReadAsync())
|
|
|
|
|
{
|
|
|
|
|
return new Quote
|
|
|
|
|
{
|
|
|
|
|
Id = reader.GetInt32(reader.GetOrdinal("Id")),
|
|
|
|
|
Content = reader.GetString(reader.GetOrdinal("Content")),
|
|
|
|
|
Like = reader.GetInt32(reader.GetOrdinal("Like")),
|
|
|
|
|
Langue = reader.GetString(reader.GetOrdinal("Langue")),
|
|
|
|
|
// Placeholders
|
|
|
|
|
Charac = reader.IsDBNull(reader.GetOrdinal("Charac")) ? null : reader.GetString(reader.GetOrdinal("Charac")),
|
|
|
|
|
ImgPath = reader.IsDBNull(reader.GetOrdinal("ImgPath")) ? null : reader.GetString(reader.GetOrdinal("ImgPath")),
|
|
|
|
|
TitleSrc = reader.IsDBNull(reader.GetOrdinal("TitleSrc")) ? null : reader.GetString(reader.GetOrdinal("TitleSrc")),
|
|
|
|
|
DateSrc = reader.GetDateTime(reader.GetOrdinal("DateSrc")),
|
|
|
|
|
UserProposition = reader.IsDBNull(reader.GetOrdinal("UserProposition")) ? null : reader.GetString(reader.GetOrdinal("UserProposition"))
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<List<Quote>> getSomeQuote(int nb, int page)
|
|
|
|
|