Ajout de Route
continuous-integration/drone/push Build is failing Details

pull/138/head
Hugo LIVET 2 years ago
parent 3963d6dbd8
commit 12fefde1d7

@ -138,4 +138,37 @@ $app->post('/Inscrit/add/', function(Request $request, Response $response, array
->withStatus(500);
}
});
$app->delete('/Inscrit/delete/', function (Request $request, Response $response, array $args) {
$email = $request->getParsedBody()["email"];
$query = "DELETE FROM Inscrit WHERE mail=:mail";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':mail', $email, PDO::PARAM_STR);
$result = $stmt->execute();
$db = null;
$response->getBody()->write(json_encode($result));
return $response
->withHeader('content-type', 'application/json')
->withStatus(200);
} catch(PDOException $e){
$error = array("message" => $e->getMessage());
$response->getBody()->write(json_encode($error));
return $response
->withHeader('content-type', 'application/json')
->withStatus(500);
}
});
?>

@ -22,6 +22,7 @@ namespace Data
private const string POST_EMAIL_INSCRIT_DATA_URL = ROOT_URL+"Inscrit/FromMail/";
private const string PUT_PASSWORD_INSCRIT_DATA_URL = ROOT_URL+"Inscrit/UpdatePassword/";
private const string POST_ADD_INSCRIT_DATA_URL = ROOT_URL + "Inscrit/add/";
private const string DELETE_INSCRIT_DATA_URL = ROOT_URL + "Inscrit/delete/";
//add all routes
@ -89,5 +90,28 @@ namespace Data
}
public static async Task<bool> DeleteInscritAsync(string email)
{
var dataBody = new Dictionary<string, string> { { "email", email } };
var reponse =
cli.SendAsync(
new HttpRequestMessage(HttpMethod.Delete, DELETE_INSCRIT_DATA_URL)
{
Content = new FormUrlEncodedContent(dataBody)
})
.Result;
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
}
}

@ -19,7 +19,7 @@ namespace Data
}
public bool SupprimerInscrit(Inscrit inscrit)
{
throw new NotImplementedException();
return ClientAPI.DeleteInscritAsync(inscrit.Mail).GetAwaiter().GetResult();
}
public bool ModifierMdpInscrit(string mail, string nouveauMdp)
{
@ -36,7 +36,12 @@ namespace Data
}
public bool EmailDisponible(string mail)
{
throw new NotImplementedException();
List<Inscrit> inscrits = ClientAPI.GetInscritAsync(mail).GetAwaiter().GetResult();
if (inscrits.Count >= 1)
{
return false;
}
return true;
}

@ -17,7 +17,7 @@ using System.Reflection.PortableExecutable;
namespace LinqToPgSQL
{
public class PersLinqToPgSQL : IPersistanceManager
public class PersLinqToPgSQL /*: IPersistanceManager*/
{
private Hash hash = new Hash();
private static string connexionBDD = String.Format("Server=2.3.8.130; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer");

@ -2,7 +2,7 @@
namespace Data
{
public class PersStub : IPersistanceManager
public class PersStub /*: IPersistanceManager*/
{
private List<Inscrit> lesInscrits = new List<Inscrit>();
@ -122,10 +122,7 @@ namespace Data
return LoadOperation.LoadOperationsFromOFX(ofx);
}
string IPersistanceManager.GetId(string mail)
{
throw new NotImplementedException();
}
public List<Banque> LoadBanqueId(int id)
{

@ -20,7 +20,7 @@ public partial class Inscription : ContentPage
}
else
{
if(EntryNewPassword.Text.Equals(EntryConfirmationPassword.Text)) {
/*if(EntryNewPassword.Text.Equals(EntryConfirmationPassword.Text)) {
if (Mgr.existEmail(EntryNewMail.Text))
{
AffichError("Mail existant", "un compte porte déjà cette adresse mail, veuillez en changer", "OK");
@ -43,15 +43,15 @@ public partial class Inscription : ContentPage
else
{
AffichError("Mot de passe de confirmation invalide", "Veuillez mettre deux mots de passe identiques", "OK");
}
}*/
}
}
private void ValideCode(object sender, EventArgs e)
{
if (EntryCodeRecept.Text == code)
{
Inscrit inscrit = new Inscrit(Mgr.lastInscrit() + 1, EntryNewName.Text, EntryNewMail.Text, EntryNewSurname.Text, EntryNewPassword.Text);
Mgr.createInscrit(inscrit);
//Inscrit inscrit = new Inscrit(Mgr.lastInscrit() + 1, EntryNewName.Text, EntryNewMail.Text, EntryNewSurname.Text, EntryNewPassword.Text);
//Mgr.createInscrit(inscrit);
AffichError("compte créé", "Compte bien créé", "OK");
NavigateTo("..");
}

@ -79,91 +79,21 @@ namespace Model
Pers = persistance;
}
public void SupprimerInscritBdd(Inscrit i)
{
Pers.SupprimerInscritBdd(i);
}
public string GetId(string mail)
{
return Pers.GetId(mail);
}
public void LoadBanques()
{
User.LesBanques = Pers.LoadBanqueId(User.Id);
if (User.LesBanques.Count() > 0)
{
SelectedBanque = User.LesBanques[0];
}
}
public void supprimerToutesBanquesBdd(Inscrit inscrit)
{
Pers.SupprimerToutesBanquesBdd(inscrit);
}
public void createInscrit(Inscrit inscrit)
{
Pers.CreateInscrit(inscrit);
}
public string lastInscrit()
{
return Pers.LastInscrit();
}
public bool existEmail(string mail)
{
return Pers.ExistEmail(mail);
}
public void changePasswordBdd(string mail, string newMdp)
{
Pers.ChangePasswordBdd(mail, newMdp);
}
public string recupMdpBdd(string mail)
{
return Pers.RecupMdpBdd(mail);
}
public bool isEqualHash(string mdpBdd, string mdpSent)
{
return hash.IsEqualHash(mdpBdd, mdpSent);
}
public void createUser(string mail)
{
//User = new Inscrit(mail, GetId(mail));
User = Pers.GetInscrit(mail);
}
public int recupTotalSolde()
{
Solde = Pers.CalculTotalSoldeComtpe(User);
return Solde;
}
public void deconnexion()
{
User = null;
}
public bool testConnexionAsDatabase()
{
return Pers.TestConnexionAsDatabase();
}
public void importBanques()
{
BanquesDisponibleInApp = Pers.ImportBanques();
}
public IList<Compte> getCompteFromOFX(string ofx)
{
return Pers.GetCompteFromOFX(ofx);
}
}
}

@ -60,3 +60,15 @@ foreach (Inscrit i in modif)
{
Console.WriteLine(i);
}
Console.WriteLine("\n----Modifs----\n");
bool rrr = ClientAPI.DeleteInscritAsync("livet.hugo2003@gmail.com").GetAwaiter().GetResult();
Console.WriteLine("Del user : " + rr + "\n");
modif = ClientAPI.GetInscritsAsync().GetAwaiter().GetResult();
foreach (Inscrit i in modif)
{
Console.WriteLine(i);
}
Loading…
Cancel
Save