Compare commits
44 Commits
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Npgsql" Version="6.0.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Model\Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using Npgsql;
|
||||
using Model;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
|
||||
namespace LinqToPgSQL
|
||||
{
|
||||
public class PersLinqToPgSQL : IPersistanceManager
|
||||
{
|
||||
string connexionBDD = String.Format("Server=90.114.135.116; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer");
|
||||
public string LoadInscrit(string id, string mdp)
|
||||
{
|
||||
string resultat="";
|
||||
var conn = new NpgsqlConnection(connexionBDD);
|
||||
Console.Out.WriteLine("Ouverture de la connection");
|
||||
conn.Open();
|
||||
NpgsqlParameter p1 = new NpgsqlParameter { ParameterName = "p", Value = id };
|
||||
NpgsqlParameter p2 = new NpgsqlParameter { ParameterName = "p2", Value = mdp };
|
||||
NpgsqlCommand cmd = new NpgsqlCommand($"SELECT id FROM INSCRIT WHERE (nom=(@p) OR mail=(@p)) AND mdp=@p2", conn);
|
||||
cmd.Parameters.Add(p1);
|
||||
cmd.Parameters.Add(p2);
|
||||
NpgsqlDataReader dr = cmd.ExecuteReader();
|
||||
try
|
||||
{
|
||||
dr.Read();
|
||||
resultat = dr.GetString(0);
|
||||
dr.Close();
|
||||
return resultat;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex+"Utilisateur inconnu");
|
||||
dr.Close();
|
||||
return "null";//a changer doit retester
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Revoir la BDD, probleme de clé étrangère de devise*/
|
||||
public async void SupprimerInscritBdd(Inscrit i)
|
||||
{
|
||||
/*List<Inscrit> ListeInscrits = new List<Inscrit>(LoadInscrit());*/
|
||||
|
||||
var conn = new NpgsqlConnection(connexionBDD);
|
||||
Console.Out.WriteLine("Ouverture de la connection");
|
||||
conn.Open();
|
||||
string requete = $"DELETE FROM INSCRIT WHERE id=(@p)";
|
||||
string requeteFKey = $"DELETE FROM DEVISEINSCRIT WHERE idInscrit=(@p2)";
|
||||
using (var command1 = new NpgsqlCommand(requeteFKey, conn))
|
||||
{
|
||||
command1.Parameters.AddWithValue("p2", i.Id);
|
||||
await command1.ExecuteNonQueryAsync();
|
||||
}
|
||||
using (var command = new NpgsqlCommand(requete, conn))
|
||||
{
|
||||
command.Parameters.AddWithValue("p", i.Id);
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using Model;
|
||||
|
||||
namespace TestsUnitaires
|
||||
{
|
||||
public class TU_Compte
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void Ctor_Compte()
|
||||
{
|
||||
Compte c = new Compte("Crédit Agricole", 20000);
|
||||
Assert.NotNull(c);
|
||||
Assert.Equal("Crédit Agricole", c.Nom);
|
||||
Assert.Equal(20000, c.Solde);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
namespace TestsUnitaires
|
||||
{
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\WINDOWS\System32\SHELL32.dll,294
|
||||
[ViewState]
|
||||
Mode=
|
||||
Vid=
|
||||
FolderType=Generic
|
Loading…
Reference in new issue