|
|
|
@ -8,9 +8,29 @@ namespace WF_WebAdmin.Service
|
|
|
|
|
private const string connectionString =
|
|
|
|
|
"Host=localhost;Port=5432;Database=wikifantasy3;Username=postgres;Password=postgres";
|
|
|
|
|
|
|
|
|
|
public Task addQuote(Quote quote)
|
|
|
|
|
public async Task addQuote(Quote quote)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
using var con = new NpgsqlConnection(connectionString);
|
|
|
|
|
await con.OpenAsync();
|
|
|
|
|
|
|
|
|
|
// SQL pour insérer une nouvelle citation dans la base de données
|
|
|
|
|
var sql = @"
|
|
|
|
|
INSERT INTO quote (id_quote, content, likes,langue)
|
|
|
|
|
VALUES (@Id ,@Content, @Likes, @Langue, @IsValide, @CreatedAt)
|
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
using var cmd = new NpgsqlCommand(sql, con);
|
|
|
|
|
|
|
|
|
|
// Ajouter les paramètres pour éviter les injections SQL
|
|
|
|
|
cmd.Parameters.AddWithValue("@Id", quote.Id);
|
|
|
|
|
cmd.Parameters.AddWithValue("@Content", quote.Content);
|
|
|
|
|
cmd.Parameters.AddWithValue("@Likes", quote.Like);
|
|
|
|
|
cmd.Parameters.AddWithValue("@Langue", quote.Langue);
|
|
|
|
|
|
|
|
|
|
// Exécution de la commande
|
|
|
|
|
await cmd.ExecuteNonQueryAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<Quote>> getAllQuote()
|
|
|
|
|