ClientAPI #138

Merged
hugo.livet merged 21 commits from ClientAPI into master 2 years ago

@ -10,6 +10,7 @@ steps:
- name: build
image: mcr.microsoft.com/dotnet/sdk:6.0
commands:
- dotnet add package Newtonsoft.Json
- cd Sources
- dotnet workload restore
- dotnet restore CI_MAUI.sln
@ -27,6 +28,7 @@ steps:
- name: code-analysis
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6
commands:
- dotnet add package Newtonsoft.Json
- cd Sources/
- dotnet workload restore
- dotnet restore CI_MAUI.sln

@ -15,6 +15,11 @@ $app->get('/', function (Request $request, Response $response, $args) {
});
require __DIR__.'/../routes/Inscrit.php';
require __DIR__.'/../routes/Banque.php';
require __DIR__.'/../routes/Compte.php';
require __DIR__.'/../routes/Operation.php';
require __DIR__.'/../routes/Planification.php';
require __DIR__.'/../routes/Echeance.php';
$app->run();
?>

@ -0,0 +1,140 @@
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use OpenApi\Annotations as OA;
/**
* @OA\Info(title="My First API", version="0.1")
*/
$app->addBodyParsingMiddleware();
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);
/**
* @OA\Get(path="/api/Banque",
* @OA\Response(response="200", description="Succes")
* @OA\Response(response="500", description="Bdd Error")
* )
*/
$app->get('/Banque/', function(Request $request, Response $response){
$query = "SELECT * FROM Banque";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->query($query);
$inscrits = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
$response->getBody()->write(json_encode($inscrits));
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);
}
});
$app->post('/Banque/FromId/', function(Request $request, Response $response,array $args){
$id = $request->getParsedBody()["id"];
$query = 'SELECT * FROM Banque WHERE nom IN (SELECT nomBanque FROM InscrBanque WHERE idInscrit=:id)';
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':id', $id, PDO::PARAM_STR);
$stmt->execute();
$inscrit = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
$response->getBody()->write(json_encode($inscrit));
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);
}
});
$app->post('/Banque/add/', function(Request $request, Response $response, array $args){
$nom = $request->getParsedBody()["nom"];
$idInscrit = $request->getParsedBody()["idInscrit"];
$query = "INSERT INTO InscrBanque (nomBanque, idInscrit) VALUES (:nom, :idI)";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':nom', $nom, PDO::PARAM_STR);
$stmt->bindValue(':idI', $idInscrit, 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);
}
});
$app->delete('/Banque/delete/', function (Request $request, Response $response, array $args) {
$nom = $request->getParsedBody()["nom"];
$idInscrit = $request->getParsedBody()["idInscrit"];
$query = "DELETE FROM InscrBanque WHERE nomBanque=:nom AND idInscrit=:idI";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':nom', $nom, PDO::PARAM_STR);
$stmt->bindValue(':idI', $idInscrit, 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);
}
});
?>

@ -0,0 +1,116 @@
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use OpenApi\Annotations as OA;
/**
* @OA\Info(title="My First API", version="0.1")
*/
$app->addBodyParsingMiddleware();
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);
/**
* @OA\Get(path="/api/Compte",
* @OA\Response(response="200", description="Succes")
* @OA\Response(response="500", description="Bdd Error")
* )
*/
$app->post('/Compte/FromIdInscrit/', function(Request $request, Response $response,array $args){
$idInscrit = $request->getParsedBody()["id"];
$query = 'SELECT * FROM Compte WHERE idInscritBanque=:id';
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':id', $idInscrit, PDO::PARAM_STR);
$stmt->execute();
$compte = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
$response->getBody()->write(json_encode($compte));
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);
}
});
$app->post('/Compte/add/', function(Request $request, Response $response, array $args){
$nom = $request->getParsedBody()["nom"];
$idInscrit = $request->getParsedBody()["idInscrit"];
$query = "INSERT INTO Compte (nom, idInscritBanque) VALUES (:nom, :idI)";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':nom', $nom, PDO::PARAM_STR);
$stmt->bindValue(':idI', $idInscrit, 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);
}
});
$app->delete('/Compte/delete/', function (Request $request, Response $response, array $args) {
$nom = $request->getParsedBody()["nom"];
$idInscrit = $request->getParsedBody()["idInscrit"];
$query = "DELETE FROM Compte WHERE nom=:nom AND idInscritBanque=:idI";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':nom', $nom, PDO::PARAM_STR);
$stmt->bindValue(':idI', $idInscrit, 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);
}
});
?>

@ -0,0 +1,125 @@
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use OpenApi\Annotations as OA;
/**
* @OA\Info(title="My First API", version="0.1")
*/
$app->addBodyParsingMiddleware();
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);
/**
* @OA\Get(path="/api/Echeance",
* @OA\Response(response="200", description="Succes")
* @OA\Response(response="500", description="Bdd Error")
* )
*/
$app->post('/Echeance/FromIdCompte/', function(Request $request, Response $response,array $args){
$idCompte = $request->getParsedBody()["id"];
$query = 'SELECT * FROM Echeancier WHERE compte=:id';
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':id', $idCompte, PDO::PARAM_STR);
$stmt->execute();
$ope = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
$response->getBody()->write(json_encode($ope));
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);
}
});
$app->post('/Echeance/add/', function(Request $request, Response $response, array $args){
$compte = $request->getParsedBody()["compte"];
$nom = $request->getParsedBody()["nom"];
$montant = $request->getParsedBody()["montant"];
$dateO = $request->getParsedBody()["dateO"];
$methodePayement = $request->getParsedBody()["methodePayement"];
$isDebit = $request->getParsedBody()["isDebit"];
$tag = $request->getParsedBody()["tag"];
$query = "INSERT INTO Echeancier (compte, nom, montant, dateO, methodePayement, isDebit, tag) SELECT :compte,:nom,:montant, STR_TO_DATE(:dateO, '%d/%m/%Y %H:%i:%s' ), :methodePayement, :isD ,:tag;";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':compte', $compte, PDO::PARAM_STR);
$stmt->bindValue(':nom', $nom, PDO::PARAM_STR);
$stmt->bindValue(':montant', $montant, PDO::PARAM_STR);
$stmt->bindValue(':dateO', $dateO, PDO::PARAM_STR);
$stmt->bindValue(':methodePayement', $methodePayement, PDO::PARAM_STR);
$stmt->bindValue(':isD', $isDebit, PDO::PARAM_BOOL);
$stmt->bindValue(':tag', $tag, 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);
}
});
$app->delete('/Echeance/delete/', function (Request $request, Response $response, array $args) {
$compte = $request->getParsedBody()["compte"];
$nom = $request->getParsedBody()["nom"];
$query = "DELETE FROM Echeancier WHERE compte=:compte AND nom=:nom";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':compte', $compte, PDO::PARAM_STR);
$stmt->bindValue(':nom', $nom, 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);
}
});
?>

@ -8,8 +8,6 @@ use OpenApi\Annotations as OA;
* @OA\Info(title="My First API", version="0.1")
*/
$app = AppFactory::create();
$app->addBodyParsingMiddleware();
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);
@ -138,4 +136,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);
}
});
?>

@ -0,0 +1,127 @@
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use OpenApi\Annotations as OA;
/**
* @OA\Info(title="My First API", version="0.1")
*/
$app->addBodyParsingMiddleware();
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);
/**
* @OA\Get(path="/api/Operation",
* @OA\Response(response="200", description="Succes")
* @OA\Response(response="500", description="Bdd Error")
* )
*/
$app->post('/Operation/FromIdCompte/', function(Request $request, Response $response,array $args){
$idCompte = $request->getParsedBody()["id"];
$query = 'SELECT * FROM Operation WHERE compte=:id';
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':id', $idCompte, PDO::PARAM_STR);
$stmt->execute();
$ope = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
$response->getBody()->write(json_encode($ope));
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);
}
});
$app->post('/Operation/add/', function(Request $request, Response $response, array $args){
$compte = $request->getParsedBody()["compte"];
$nom = $request->getParsedBody()["nom"];
$montant = $request->getParsedBody()["montant"];
$dateO = $request->getParsedBody()["dateO"];
$methodePayement = $request->getParsedBody()["methodePayement"];
$isDebit = $request->getParsedBody()["isDebit"];
$tag = $request->getParsedBody()["tag"];
$fromBanque = $request->getParsedBody()["fromBanque"];
$query = "INSERT INTO Operation (compte, nom, montant, dateO, methodePayement, isDebit, fromBanque, tag) SELECT :compte,:nom,:montant, STR_TO_DATE(:dateO, '%d/%m/%Y %H:%i:%s' ), :methodePayement, :isD, :fromBanque, :tag;";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':compte', $compte, PDO::PARAM_STR);
$stmt->bindValue(':nom', $nom, PDO::PARAM_STR);
$stmt->bindValue(':montant', $montant, PDO::PARAM_STR);
$stmt->bindValue(':dateO', $dateO, PDO::PARAM_STR);
$stmt->bindValue(':methodePayement', $methodePayement, PDO::PARAM_STR);
$stmt->bindValue(':isD', $isDebit, PDO::PARAM_BOOL);
$stmt->bindValue(':tag', $tag, PDO::PARAM_STR);
$stmt->bindValue(':fromBanque', $fromBanque, PDO::PARAM_BOOL);
$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);
}
});
$app->delete('/Operation/delete/', function (Request $request, Response $response, array $args) {
$compte = $request->getParsedBody()["compte"];
$nom = $request->getParsedBody()["nom"];
$query = "DELETE FROM Operation WHERE compte=:compte AND nom=:nom";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':compte', $compte, PDO::PARAM_STR);
$stmt->bindValue(':nom', $nom, 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);
}
});
?>

@ -0,0 +1,125 @@
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use OpenApi\Annotations as OA;
/**
* @OA\Info(title="My First API", version="0.1")
*/
$app->addBodyParsingMiddleware();
$app->addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);
/**
* @OA\Get(path="/api/Planification",
* @OA\Response(response="200", description="Succes")
* @OA\Response(response="500", description="Bdd Error")
* )
*/
$app->post('/Planification/FromIdCompte/', function(Request $request, Response $response,array $args){
$idCompte = $request->getParsedBody()["id"];
$query = 'SELECT * FROM Planification WHERE compte=:id';
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':id', $idCompte, PDO::PARAM_STR);
$stmt->execute();
$ope = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
$response->getBody()->write(json_encode($ope));
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);
}
});
$app->post('/Planification/add/', function(Request $request, Response $response, array $args){
$compte = $request->getParsedBody()["compte"];
$nom = $request->getParsedBody()["nom"];
$montant = $request->getParsedBody()["montant"];
$dateO = $request->getParsedBody()["dateO"];
$methodePayement = $request->getParsedBody()["methodePayement"];
$isDebit = $request->getParsedBody()["isDebit"];
$tag = $request->getParsedBody()["tag"];
$query = "INSERT INTO Planification (compte, nom, montant, dateO, methodePayement, isDebit, tag) SELECT :compte,:nom,:montant, STR_TO_DATE(:dateO, '%d/%m/%Y %H:%i:%s' ), :methodePayement, :isD ,:tag;";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':compte', $compte, PDO::PARAM_STR);
$stmt->bindValue(':nom', $nom, PDO::PARAM_STR);
$stmt->bindValue(':montant', $montant, PDO::PARAM_STR);
$stmt->bindValue(':dateO', $dateO, PDO::PARAM_STR);
$stmt->bindValue(':methodePayement', $methodePayement, PDO::PARAM_STR);
$stmt->bindValue(':isD', $isDebit, PDO::PARAM_BOOL);
$stmt->bindValue(':tag', $tag, 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);
}
});
$app->delete('/Planification/delete/', function (Request $request, Response $response, array $args) {
$compte = $request->getParsedBody()["compte"];
$nom = $request->getParsedBody()["nom"];
$query = "DELETE FROM Planification WHERE compte=:compte AND nom=:nom";
try{
$db = new Database();
$conn = $db->connect();
$stmt = $conn->prepare($query);
$stmt->bindValue(':compte', $compte, PDO::PARAM_STR);
$stmt->bindValue(':nom', $nom, 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);
}
});
?>

@ -0,0 +1,483 @@
using Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace Data
{
public static class ClientAPI
{
private const string ROOT_URL = "http://82.64.164.20:8888/";
//routes inscrit
private const string GET_INSCRITS_DATA_URL = ROOT_URL+"Inscrit/";
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/";
//routes banque
private const string GET_BANQUES_DATA_URL = ROOT_URL + "Banque/";
private const string POST_BANQUES_INSCRIT_DATA_URL = ROOT_URL + "Banque/FromId/";
private const string POST_ADD_BANQUE_INSCRIT_DATA_URL = ROOT_URL + "Banque/add/";
private const string DELETE_BANQUE_INSCRIT_DATA_URL = ROOT_URL + "Banque/delete/";
//routes compte
private const string POST_COMPTE_INSCRIT_DATA_URL = ROOT_URL + "Compte/FromIdInscrit/";
private const string POST_ADD_COMPTE_INSCRIT_DATA_URL = ROOT_URL + "Compte/add/";
private const string DELETE_COMPTE_INSCRIT_DATA_URL = ROOT_URL + "Compte/delete/";
//routes operation
private const string POST_OPERATION_COMPTE_DATA_URL = ROOT_URL + "Operation/FromIdCompte/";
private const string POST_ADD_OPERATION_COMPTE_DATA_URL = ROOT_URL + "Operation/add/";
private const string DELETE_OPERATION_COMPTE_DATA_URL = ROOT_URL + "Operation/delete/";
//routes planification
private const string POST_PLANIFICATION_COMPTE_DATA_URL = ROOT_URL + "Planification/FromIdCompte/";
private const string POST_ADD_PLANIFICATION_COMPTE_DATA_URL = ROOT_URL + "Planification/add/";
private const string DELETE_PLANIFICATION_COMPTE_DATA_URL = ROOT_URL + "Planification/delete/";
//routes echeance
private const string POST_ECHEANCE_COMPTE_DATA_URL = ROOT_URL + "Echeance/FromIdCompte/";
private const string POST_ADD_ECHEANCE_COMPTE_DATA_URL = ROOT_URL + "Echeance/add/";
private const string DELETE_ECHEANCE_COMPTE_DATA_URL = ROOT_URL + "Echeance/delete/";
//routes utilitaire
private const string TEST_API_STATEMENT = ROOT_URL;
private static HttpClient cli = new HttpClient();
//Inscrit
public static async Task<List<Inscrit>> GetInscritsAsync()
{
HttpResponseMessage reponse = await cli.GetAsync(GET_INSCRITS_DATA_URL);
if(reponse.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<List<Inscrit>>(await reponse.Content.ReadAsStringAsync());
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<List<Inscrit>> GetInscritAsync(string email)
{
var dataBody = new Dictionary<string, string> { { "email", email } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_EMAIL_INSCRIT_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<List<Inscrit>>(await reponse.Content.ReadAsStringAsync());
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> PutPasswordInscritAsync(string email, string password)
{
var dataBody = new Dictionary<string, string> { { "email", email }, { "password", password } };
HttpResponseMessage reponse = await cli.PutAsJsonAsync(PUT_PASSWORD_INSCRIT_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> PostAddInscritAsync(string nom, string prenom, string email, string password)
{
var dataBody = new Dictionary<string, string> { { "nom", nom }, { "prenom", prenom }, { "email", email }, { "password", password } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_ADD_INSCRIT_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
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());
}
}
//Banque
public static async Task<List<Banque>> GetBanquesAsync()
{
HttpResponseMessage reponse = await cli.GetAsync(GET_BANQUES_DATA_URL);
if (reponse.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<List<Banque>>(await reponse.Content.ReadAsStringAsync());
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<List<Banque>> GetBanqueAsync(string id)
{
var dataBody = new Dictionary<string, string> { { "id", id } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_BANQUES_INSCRIT_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<List<Banque>>(await reponse.Content.ReadAsStringAsync());
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> PostAddBanqueInscritAsync(string nomBanque, string idInscrit)
{
var dataBody = new Dictionary<string, string> { { "nom", nomBanque }, { "idInscrit", idInscrit } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_ADD_BANQUE_INSCRIT_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> DeleteBanqueInscritAsync(string nomBanque, string idInscrit)
{
var dataBody = new Dictionary<string, string> { { "nom", nomBanque }, { "idInscrit", idInscrit } };
var reponse =
cli.SendAsync(
new HttpRequestMessage(HttpMethod.Delete, DELETE_BANQUE_INSCRIT_DATA_URL)
{
Content = new FormUrlEncodedContent(dataBody)
})
.Result;
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
//Comptes
public static async Task<List<Compte>> GetCompteAsync(string id)
{
var dataBody = new Dictionary<string, string> { { "id", id } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_COMPTE_INSCRIT_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<List<Compte>>(await reponse.Content.ReadAsStringAsync());
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> PostAddCompteInscritAsync(string nomCompte, string idInscrit)
{
var dataBody = new Dictionary<string, string> { { "nom", nomCompte }, { "idInscrit", idInscrit } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_ADD_COMPTE_INSCRIT_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> DeleteCompteInscritAsync(string nomCompte, string idInscrit)
{
var dataBody = new Dictionary<string, string> { { "nom", nomCompte }, { "idInscrit", idInscrit } };
var reponse =
cli.SendAsync(
new HttpRequestMessage(HttpMethod.Delete, DELETE_COMPTE_INSCRIT_DATA_URL)
{
Content = new FormUrlEncodedContent(dataBody)
})
.Result;
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
//Operations
public static async Task<List<Operation>> GetOperationAsync(string id)
{
var dataBody = new Dictionary<string, string> { { "id", id } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_OPERATION_COMPTE_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<List<Operation>>(await reponse.Content.ReadAsStringAsync());
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> PostAddOperationInscritAsync(Compte compte, Operation operation)
{
var dataBody = new Dictionary<string, string>
{
{ "compte", compte.Identifiant },
{ "nom", operation.IntituleOperation },
{ "montant", operation.Montant.ToString() },
{ "dateO", operation.DateOperation.ToString() },
{ "methodePayement", operation.ModePayement.ToString() },
{ "isDebit", operation.IsDebit.ToString() },
{ "tag", operation.Tag.ToString() },
{ "fromBanque", operation.FromBanque.ToString() }
};
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_ADD_OPERATION_COMPTE_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> DeleteOperationInscritAsync(string idCompte, string nomOpe)
{
var dataBody = new Dictionary<string, string> { { "compte", idCompte }, { "nom", nomOpe } };
var reponse =
cli.SendAsync(
new HttpRequestMessage(HttpMethod.Delete, DELETE_OPERATION_COMPTE_DATA_URL)
{
Content = new FormUrlEncodedContent(dataBody)
})
.Result;
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
//Planifications
public static async Task<List<Planification>> GetPlanificationAsync(string id)
{
var dataBody = new Dictionary<string, string> { { "id", id } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_PLANIFICATION_COMPTE_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<List<Planification>>(await reponse.Content.ReadAsStringAsync());
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> PostAddPlanificationInscritAsync(Compte compte, Planification planification)
{
var dataBody = new Dictionary<string, string>
{
{ "compte", compte.Identifiant },
{ "nom", planification.IntituleOperation },
{ "montant", planification.Montant.ToString() },
{ "dateO", planification.DateOperation.ToString() },
{ "methodePayement", planification.ModePayement.ToString() },
{ "isDebit", planification.IsDebit.ToString() },
{ "tag", planification.Tag.ToString() }
};
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_ADD_PLANIFICATION_COMPTE_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> DeletePlanificationInscritAsync(string idCompte, string nomOpe)
{
var dataBody = new Dictionary<string, string> { { "compte", idCompte }, { "nom", nomOpe } };
var reponse =
cli.SendAsync(
new HttpRequestMessage(HttpMethod.Delete, DELETE_PLANIFICATION_COMPTE_DATA_URL)
{
Content = new FormUrlEncodedContent(dataBody)
})
.Result;
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
//Echeances
public static async Task<List<Echeance>> GetEcheanceAsync(string id)
{
var dataBody = new Dictionary<string, string> { { "id", id } };
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_ECHEANCE_COMPTE_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<List<Echeance>>(await reponse.Content.ReadAsStringAsync());
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> PostAddEcheanceInscritAsync(Compte compte, Echeance echeance)
{
var dataBody = new Dictionary<string, string>
{
{ "compte", compte.Identifiant },
{ "nom", echeance.IntituleOperation },
{ "montant", echeance.Montant.ToString() },
{ "dateO", echeance.DateOperation.ToString() },
{ "methodePayement", echeance.ModePayement.ToString() },
{ "isDebit", echeance.IsDebit.ToString() },
{ "tag", echeance.Tag.ToString() }
};
HttpResponseMessage reponse = await cli.PostAsJsonAsync(POST_ADD_ECHEANCE_COMPTE_DATA_URL, dataBody);
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
public static async Task<bool> DeleteEcheanceInscritAsync(string idCompte, string nomOpe)
{
var dataBody = new Dictionary<string, string> { { "compte", idCompte }, { "nom", nomOpe } };
var reponse =
cli.SendAsync(
new HttpRequestMessage(HttpMethod.Delete, DELETE_ECHEANCE_COMPTE_DATA_URL)
{
Content = new FormUrlEncodedContent(dataBody)
})
.Result;
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
throw new HttpRequestException(reponse.StatusCode.ToString());
}
}
//Utilitaires
public static async Task<bool> GetStateApi()
{
HttpResponseMessage reponse = await cli.GetAsync(TEST_API_STATEMENT);
if (reponse.IsSuccessStatusCode)
{
return true;
}
else
{
return false;
}
}
}
}

@ -18,6 +18,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Npgsql" Version="6.0.7" />
</ItemGroup>

@ -13,6 +13,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Npgsql" Version="6.0.7" />
</ItemGroup>

@ -99,7 +99,7 @@ namespace Data
row = "";
}
}
compteEnCoursDeSaisie.ajouterOperation(new Operation(intituleOperation, montant, dateOperation, modePayement, isDebit));
compteEnCoursDeSaisie.ajouterOperation(new Operation(intituleOperation, montant, dateOperation, modePayement, TagOperation.None, isDebit));
}
else
{

@ -0,0 +1,133 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Data
{
public class PersAPI : IPersistanceManager
{
// /!\ Toutes les méthodes ici permettent d'uniquement manipuler une stratégie de persistance
// /!\ et ne doit en aucun cas manipuler la mémoire !
//actions sur les inscrits
public bool AjouterInscrit(Inscrit inscrit)
{
return ClientAPI.PostAddInscritAsync(inscrit.Nom, inscrit.Prenom, inscrit.Mail, inscrit.Mdp).GetAwaiter().GetResult();
}
public bool SupprimerInscrit(Inscrit inscrit)
{
return ClientAPI.DeleteInscritAsync(inscrit.Mail).GetAwaiter().GetResult();
}
public bool ModifierMdpInscrit(string mail, string nouveauMdp)
{
return ClientAPI.PutPasswordInscritAsync(mail,nouveauMdp).GetAwaiter().GetResult();
}
public Inscrit RecupererInscrit(string mail)
{
List<Inscrit> inscrits = ClientAPI.GetInscritAsync(mail).GetAwaiter().GetResult();
if(inscrits.Count >= 1)
{
throw new ArgumentException("Cet email contient plusieurs utilisateurs pour la même adresse");
}
return inscrits.FirstOrDefault();
}
public bool EmailDisponible(string mail)
{
List<Inscrit> inscrits = ClientAPI.GetInscritAsync(mail).GetAwaiter().GetResult();
if (inscrits.Count >= 1)
{
return false;
}
return true;
}
//actions sur les banques
public bool AjouterBanque(Banque banque, Inscrit inscrit)
{
return ClientAPI.PostAddBanqueInscritAsync(banque.Nom, inscrit.Id.ToString()).GetAwaiter().GetResult();
}
public bool SupprimerBanque(Banque banque, Inscrit inscrit)
{
return ClientAPI.DeleteBanqueInscritAsync(banque.Nom, inscrit.Id.ToString()).GetAwaiter().GetResult();
}
public IList<Banque> RecupererBanques(Inscrit inscrit)
{
return ClientAPI.GetBanqueAsync(inscrit.Id.ToString()).GetAwaiter().GetResult();
}
public IList<Banque> RecupererBanquesDisponible()
{
return ClientAPI.GetBanquesAsync().GetAwaiter().GetResult();
}
//actions sur les comptes
public bool AjouterCompte(Compte compte, Inscrit inscrit)
{
return ClientAPI.PostAddCompteInscritAsync(compte.Nom, inscrit.Id.ToString()).GetAwaiter().GetResult();
}
public bool SupprimerCompte(Compte compte, Inscrit inscrit)
{
return ClientAPI.DeleteCompteInscritAsync(compte.Nom, inscrit.Id.ToString()).GetAwaiter().GetResult();
}
public IList<Compte> RecupererCompte(Banque banque, Inscrit inscrit)
{
return ClientAPI.GetCompteAsync(inscrit.Id.ToString()).GetAwaiter().GetResult();
}
//actions sur les Opérations
public bool AjouterOperation(Compte compte, Operation operation)
{
return ClientAPI.PostAddOperationInscritAsync(compte,operation).GetAwaiter().GetResult();
}
public bool SupprimerOperation(Compte compte, Operation operation)
{
return ClientAPI.DeleteOperationInscritAsync(compte.Identifiant, operation.IntituleOperation).GetAwaiter().GetResult();
}
public IList<Operation> RecupererOperation(Compte compte)
{
return ClientAPI.GetOperationAsync(compte.Identifiant).GetAwaiter().GetResult();
}
//actions sur les Planifications
public bool AjouterPlanification(Compte compte, Planification planification)
{
return ClientAPI.PostAddPlanificationInscritAsync(compte, planification).GetAwaiter().GetResult();
}
public bool SupprimerPlanification(Compte compte, Planification planification)
{
return ClientAPI.DeletePlanificationInscritAsync(compte.Identifiant, planification.IntituleOperation).GetAwaiter().GetResult();
}
public IList<Planification> RecupererPlanification(Compte compte)
{
return ClientAPI.GetPlanificationAsync(compte.Identifiant).GetAwaiter().GetResult();
}
//actions sur les Echéances
public bool AjouterEcheance(Compte compte, Echeance echeance)
{
return ClientAPI.PostAddEcheanceInscritAsync(compte, echeance).GetAwaiter().GetResult();
}
public bool SupprimerEcheance(Compte compte, Echeance echeance)
{
return ClientAPI.DeleteEcheanceInscritAsync(compte.Identifiant, echeance.IntituleOperation).GetAwaiter().GetResult();
}
public IList<Echeance> RecupererEcheance(Compte compte)
{
return ClientAPI.GetEcheanceAsync(compte.Identifiant).GetAwaiter().GetResult();
}
//actions utilitaire
public bool TestConnexion()
{
return ClientAPI.GetStateApi().GetAwaiter().GetResult();
}
}
}

@ -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");
@ -296,11 +296,11 @@ namespace LinqToPgSQL
return ListeCompte;
}
public List<Banque> LoadBanqueId(string id)
public List<Banque> LoadBanqueId(int id)
{
int idnombre = Int16.Parse(id);
;
List<Banque> ListeBanque = new List<Banque>();
Debug.WriteLine(idnombre);
Debug.WriteLine(id);
var conn = new NpgsqlConnection(connexionBDD);
Console.Out.WriteLine("Ouverture de la connection");
try
@ -314,7 +314,7 @@ namespace LinqToPgSQL
Environment.Exit(-1);
}
NpgsqlCommand cmd = new NpgsqlCommand("select b.nom,b.urlsite,b.urllogo from banque b, inscrbanque ib, Inscrit i where ib.idinscrit =(@p) AND ib.nombanque = b.nom AND ib.idinscrit = i.id;", conn);
cmd.Parameters.AddWithValue("p", idnombre);
cmd.Parameters.AddWithValue("p", id);
NpgsqlDataReader dataReader = cmd.ExecuteReader();
while (dataReader.Read())
{

@ -2,21 +2,21 @@
namespace Data
{
public class Stub : IPersistanceManager
public class PersStub /*: IPersistanceManager*/
{
private List<Inscrit> lesInscrits = new List<Inscrit>();
public Stub()
public PersStub()
{
lesInscrits.Add(new Inscrit(
"1",
1,
"LIVET",
"livet.hugo2003@gmail.com",
"Hugo",
"Bonjour63."
));
}
public string GetId(string mail)
public int GetId(string mail)
{
foreach(Inscrit i in lesInscrits)
{
@ -25,7 +25,7 @@ namespace Data
return i.Id;
}
}
return null;
return -1;
}
public void SupprimerInscritBdd(Inscrit inscrit)
{
@ -63,10 +63,10 @@ namespace Data
public void CreateInscrit(Inscrit inscrit){
lesInscrits.Add(inscrit);
}
public string LastInscrit()
/*public string LastInscrit()
{
return lesInscrits[lesInscrits.Count - 1].Id;
}
}*/
public bool ExistEmail(string mail)
{
foreach(Inscrit i in lesInscrits)
@ -154,7 +154,9 @@ namespace Data
return LoadOperation.LoadOperationsFromOFX(ofx);
}
public string LoadInscrit(string id, string mdp)
public List<Banque> LoadBanqueId(int id)
{
throw new NotImplementedException();
}

@ -7,11 +7,11 @@ INSERT INTO Devise VALUES('NZD','DOLLAR NEO-ZELANDAIS');
INSERT INTO Devise VALUES('ZAR','RANd');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('EVARD','LUCAS','lucasevard@gmail.com','test');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('MONCUL','STEPHANE','stef@gmail.com','teststef');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('MENFOUMETTOITOUTNU','RENAUD','renaudtoutnu@gmail.com','test000');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('YOUVOI','BENJAMIN','BENJAMIN@gmail.com','BENJAMIN');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('TUBEAU','RAOUL','raoullacouille@gmail.com','zizi');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('EVARD','LUCAS','lucasevard@gmail.com','Azerty12345678!');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('MONCUL','STEPHANE','stef@gmail.com','Azerty12345678!');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('MENFOUMETTOITOUTNU','RENAUD','renaudtoutnu@gmail.com','Azerty12345678!');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('YOUVOI','BENJAMIN','BENJAMIN@gmail.com','Azerty12345678!');
INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES('TUBEAU','RAOUL','raoullacouille@gmail.com','Azerty12345678!');
INSERT INTO DeviseInscrit VALUES('EUR','1');
INSERT INTO DeviseInscrit VALUES('JPY','2');
@ -23,6 +23,7 @@ INSERT INtO Banque(nom,urlsite,urllogo) VALUES('BNP PARIBAS','mabanque','imagesi
INSERT INtO Banque(nom,urlsite,urllogo) VALUES('CREDIT AGRICOLE','credit-agricole.fr','imageca');
INSERT INtO Banque(nom,urlsite,urllogo) VALUES('BANQUE POSTALE','labanquepostale.fr','imgbp');
INSERT INtO Banque(nom,urlsite,urllogo) VALUES('CAISSE D EPARGNE','caisse-epargne.fr','imgcaissedepargne');
INSERT INtO Banque(nom,urlsite,urllogo) VALUES('ORANGE BANK','orange.fr','cpt');
INSERT INTO InscrBanque (nomBanque,idInscrit)VALUES('BNP PARIBAS','1');
@ -36,8 +37,6 @@ INSERT INTO Compte (nom,idInscritBanque)VALUES('LIVRET A','2');
INSERT INTO Compte (nom,idInscritBanque)VALUES('LIVRET A','3');
INSERT INTO Compte (nom,idInscritBanque)VALUES('LIVRET A','4');
INSERT INTO Planification (nom,credit,compte,datep,datecrea,methodePayement) VALUES ('EDF','190','1',now(),now(),'CB');
INSERT INTO Planification (nom,credit,compte,datep,datecrea,methodePayement) VALUES ('SPOTIFY','190','2',now(),now(),'Prélevement');
INSERT INTO Planification (nom,credit,compte,datep,datecrea,methodePayement) VALUES ('NETFLIX','190','3',now(),now(),'Cheque');
INSERT INTO Planification (nom,credit,compte,datep,datecrea,methodePayement) VALUES ('PLAYSTATION PLUS','190','4',now(),now(),'Espece');
INSERT INTO `Operation` (`id`, `compte`, `nom`, `montant`, `dateO`, `methodePayement`, `isDebit`, `fromBanque`, `tag`) VALUES (NULL, '1', 'JSP MAIS JAI PAYER', '500', '2023-01-02', 'Vir', '1', '1', 'Divers')
INSERT INTO `Planification` (`id`, `compte`, `nom`, `montant`, `dateO`, `methodePayement`, `isDebit`, `tag`) VALUES (NULL, '1', 'FAUT QUE JE PAYE', '100', '2023-01-30', 'Vir', '1', 'Energie');
INSERT INTO `Echeancier` (`id`, `compte`, `nom`, `montant`, `dateO`, `methodePayement`, `isDebit`, `tag`) VALUES (NULL, '1', 'FAUT PAYER VITEEEE', '50', '2023-01-06', 'Vir', '1', 'Divers');

@ -62,44 +62,45 @@ CREATE TABLE Compte
CREATE TABLE Echeancier
(
id MEDIUMINT PRIMARY KEY AUTO_INCREMENT,
nom varchar(40),
credit numeric,
compte MEDIUMINT,
debit numeric,
dateE date,
datecrea date,
nom varchar(40),
montant numeric,
dateO date,
methodePayement varchar(20),
CONSTRAINT ck_echan CHECK (methodePayement IN ('CB','Cheque','Espece','Prélevement')),
FOREIGN KEY(compte) REFERENCES Compte(id),
UNIQUE (datecrea,compte)
isDebit boolean,
tag varchar(30),
CONSTRAINT ck_methEch CHECK (methodePayement IN ('Cb','Esp','Chq','Vir','Pre', 'None')),
CONSTRAINT ck_tagEch CHECK (tag IN ('Alimentaire','Carburant','Habitation','Energie','Telephonie','Loisir','Restauration','Divers','Transport','Transaction','Santé')),
FOREIGN KEY(compte) REFERENCES Compte(id)
);
CREATE TABLE Operation
(
id MEDIUMINT PRIMARY KEY AUTO_INCREMENT,
nom varchar(40),
credit numeric,
compte MEDIUMINT,
debit numeric,
nom varchar(40),
montant numeric,
dateO date,
datecrea date,
methodePayement varchar(20),
CONSTRAINT ck_methPaye CHECK (methodePayement IN ('CB','Cheque','Espece','Prélevement')),
FOREIGN KEY(compte) REFERENCES Compte(id),
UNIQUE (datecrea,compte)
isDebit boolean,
fromBanque boolean,
tag varchar(30),
CONSTRAINT ck_methOpe CHECK (methodePayement IN ('Cb','Esp','Chq','Vir','Pre', 'None')),
CONSTRAINT ck_tagOpe CHECK (tag IN ('Alimentaire','Carburant','Habitation','Energie','Telephonie','Loisir','Restauration','Divers','Transport','Transaction','Santé')),
FOREIGN KEY(compte) REFERENCES Compte(id)
);
CREATE TABLE Planification
(
id MEDIUMINT PRIMARY KEY AUTO_INCREMENT,
nom varchar(40),
credit numeric,
compte MEDIUMINT,
debit numeric,
dateP date,
datecrea date,
nom varchar(40),
montant numeric,
dateO date,
methodePayement varchar(20),
CONSTRAINT ck_planif CHECK (methodePayement IN ('CB','Cheque','Espece','Prélevement')),
FOREIGN KEY(compte) REFERENCES Compte(id),
UNIQUE (datecrea,compte)
isDebit boolean,
tag varchar(30),
CONSTRAINT ck_methPla CHECK (methodePayement IN ('Cb','Esp','Chq','Vir','Pre', 'None')),
CONSTRAINT ck_tagPla CHECK (tag IN ('Alimentaire','Carburant','Habitation','Energie','Telephonie','Loisir','Restauration','Divers','Transport','Transaction','Santé')),
FOREIGN KEY(compte) REFERENCES Compte(id)
);

@ -6,7 +6,7 @@ namespace IHM
{
public partial class App : Application
{
public Manager Manager { get; set; } = new Manager(new Stub());
public Manager Manager { get; set; } = new Manager(new PersAPI());
public App()
{
InitializeComponent();

@ -26,7 +26,7 @@ public partial class ChangePassword : ContentPage
}
else
{
Mgr.changePasswordBdd(MailUser, EntryNewMdp.Text);
//Mgr.changePasswordBdd(MailUser, EntryNewMdp.Text);
AffichError("mdp changé", "mot de passe bien changé", "ok");
NavigateTo("../..");
}

@ -20,7 +20,7 @@ public partial class ForgetPassword : ContentPage
{
AffichError("Email inconnue", "Aucun compte existant portant cette adresse mail", "OK");
}
if (Mgr.existEmail(EntryMail.Text))
/*if (Mgr.existEmail(EntryMail.Text))
{
Random generator = new Random();
code = generator.Next(0, 1000000).ToString("D6");
@ -28,7 +28,7 @@ public partial class ForgetPassword : ContentPage
ValidateReceptCode.IsVisible = true;
ConnexionButton.IsEnabled = false;
UpdateArc();
}
}*/
}
private async void AffichError(string s, string s1, string s2)
{

@ -20,7 +20,7 @@ public partial class MainPage : ContentPage
}
else
{
if (Mgr.existEmail(EntryMail.Text))
/*if (Mgr.existEmail(EntryMail.Text))
{
if (Mgr.isEqualHash(Mgr.recupMdpBdd(EntryMail.Text), EntryPassworld.Text))
{
@ -35,7 +35,7 @@ public partial class MainPage : ContentPage
else
{
AffichError("Compte inexistant", "Email ou mot de passe invalide", "OK");
}
}*/
}
}

@ -100,6 +100,10 @@
</MauiImage>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Data\Data.csproj" />
<ProjectReference Include="..\Modele\Model.csproj" />

@ -11,7 +11,7 @@ public partial class AjoutBanques : ContentPage
{
InitializeComponent();
BindingContext = Mgr;
Mgr.importBanques();
//Mgr.importBanques();
if (OperatingSystem.IsIOS())
{
boutonRetour.IsVisible = true;
@ -29,12 +29,12 @@ public partial class AjoutBanques : ContentPage
{
if (result.FileName.EndsWith("ofx", StringComparison.OrdinalIgnoreCase))
{
IList<Compte> lesComptes = Mgr.getCompteFromOFX(result.FullPath);
Debug.WriteLine(lesComptes.Count);
//IList<Compte> lesComptes = Mgr.getCompteFromOFX(result.FullPath);
/*Debug.WriteLine(lesComptes.Count);
foreach(Compte compte in lesComptes)
{
Mgr.User.LesBanques.First().AjouterCompte(compte);
}
}*/
}
}

@ -25,7 +25,7 @@ public partial class ChangePassword : ContentPage
}
else
{
Mgr.changePasswordBdd(MailUser, EntryNewMdp.Text);
//Mgr.changePasswordBdd(MailUser, EntryNewMdp.Text);
AffichError("mdp changé", "mot de passe bien changé", "ok");
NavigateTo("../..");
}

@ -17,11 +17,11 @@ public partial class DashBoard : ContentPage
}
if (!Mgr.testConnexionAsDatabase())
/* if (!Mgr.testConnexionAsDatabase())
{
loadPage(new ErrorPage());
}
}*/
}

@ -22,10 +22,10 @@ public partial class ErrorPage : ContentPage
public void conIsActive()
{
while (!Mgr.testConnexionAsDatabase())
/*while (!Mgr.testConnexionAsDatabase())
{
Thread.Sleep(TIME_TEST_DB);
}
}*/
ConnexionValide();
return;

@ -20,7 +20,7 @@ public partial class ForgetPassword : ContentPage
{
AffichError("Email inconnue", "Aucun compte existant portant cette adresse mail", "OK");
}
if (Mgr.existEmail(EntryMail.Text)){
/*if (Mgr.existEmail(EntryMail.Text)){
Random generator = new Random();
code = generator.Next(0, 1000000).ToString("D6");
Email.CreateMail(EntryMail.Text, code);
@ -31,7 +31,7 @@ public partial class ForgetPassword : ContentPage
else
{
AffichError("Mail inexistant", "Aucun compte possédant cette adresse email trouvé", "OK");
}
}*/
}
private async void AffichError(string s, string s1, string s2)
{

@ -11,7 +11,7 @@ public partial class GestionBanques : ContentPage
{
InitializeComponent();
BindingContext= Mgr;
Mgr.LoadBanques();
//Mgr.LoadBanques();
if (OperatingSystem.IsIOS())
{
boutonRetour.IsVisible = true;

@ -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("..");
}

@ -21,7 +21,7 @@ namespace IHM.Mobile
AffichError("Champ invalide", "Veuillez compléter tout les champs", "OK");
}
else {
if (Mgr.existEmail(EntryMail.Text))
/* if (Mgr.existEmail(EntryMail.Text))
{
if (Mgr.isEqualHash(Mgr.recupMdpBdd(EntryMail.Text), EntryPassworld.Text))
{
@ -36,13 +36,13 @@ namespace IHM.Mobile
else
{
AffichError("Compte inexistant", "Email ou mot de passe invalide", "OK");
}
}*/
}
}
private async void ConnexionValide()
{
Mgr.LoadBanques();
//Mgr.LoadBanques();
await Navigation.PopModalAsync();
}

@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
@ -27,6 +28,7 @@ namespace Model
}
private List<Compte> listeDesComptes = new List<Compte>();
[JsonConstructor]
public Banque(string nom, string urlSite, string urlLogo)
{
Nom = nom;
@ -72,5 +74,10 @@ namespace Model
throw new KeyNotFoundException();
}
public override string ToString()
{
return Nom + " " + UrlSite + " " + UrlLogo;
}
}
}

@ -1,5 +1,4 @@
using Microsoft.Maui.Graphics;
using System.Collections.Specialized;
using Newtonsoft.Json;
using System.ComponentModel;
namespace Model
@ -26,13 +25,19 @@ namespace Model
private List<Operation> lesOpe = new List<Operation>();
public List<Planification> LesPla { get; set; } = new List<Planification>();
public List<Echeance> LesEch { get; set; } = new List<Echeance>();
public Compte(string id,string nom, double solde)
[JsonConstructor]
public Compte(string id, string nom)
{
Identifiant = id;
Nom = nom;
Solde = solde;
Solde = 0;
DerniereModification = DateTime.Now;
}
public Compte(string id,string nom, double solde) : base()
{
Solde = solde;
}
public Compte(string id, string nom, double solde, List<Operation> lesOpe)
{
Identifiant = id;
@ -125,7 +130,7 @@ namespace Model
public override string ToString()
{
return Identifiant + " " + Nom + " " + Solde + " " + DerniereModification + "\n";
return Identifiant + " " + Nom + " " + Solde + " " + DerniereModification;
}
}

@ -1,5 +1,7 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -8,5 +10,33 @@ namespace Model
{
public class Echeance
{
public string IntituleOperation { get; private set; }
public double Montant { get; private set; }
public DateTime DateOperation { get; private set; }
public MethodePayement ModePayement { get; private set; }
public bool IsDebit { get; private set; }
public TagOperation Tag { get; private set; }
[JsonConstructor]
public Echeance(string intituleOperation, double montant, DateTime dateOperation, MethodePayement modePayement, TagOperation tag, bool isDebit = true)
{
IntituleOperation = intituleOperation;
Montant = montant;
DateOperation = dateOperation;
ModePayement = modePayement;
IsDebit = isDebit;
Tag = tag;
}
public override string ToString()
{
return IntituleOperation + " " + DateOperation + " " + Montant + " " + ModePayement + " " + IsDebit + " " + Tag;
}
}
}

@ -8,21 +8,50 @@ namespace Model
{
public interface IPersistanceManager
{
string GetId(string mail);
void SupprimerInscritBdd(Inscrit inscrit);
void SupprimerBanqueBdd(Inscrit inscrit, Banque banque);
void SupprimerToutesBanquesBdd(Inscrit inscrit);
void CreateInscrit(Inscrit inscrit);
string LastInscrit();
bool ExistEmail(string mail);
void ChangePasswordBdd(string mail, string newMdp);
string RecupMdpBdd(string mail);
int CalculTotalSoldeComtpe(Inscrit user);
List<Banque> LoadBanqueId(string id);
public bool TestConnexionAsDatabase();
public List<Banque> ImportBanques();
public Inscrit GetInscrit(string mail);
public IList<Compte> GetCompteFromOFX(string ofx);
// /!\ Toutes les méthodes ici permettent d'uniquement manipuler une stratégie de persistance
// /!\ et ne doit en aucun cas manipuler la mémoire !
//actions sur les inscrits
bool AjouterInscrit(Inscrit inscrit);
bool SupprimerInscrit(Inscrit inscrit);
bool ModifierMdpInscrit(string mail, string nouveauMdp);
Inscrit RecupererInscrit(string mail);
bool EmailDisponible(string mail);
//actions sur les banques
bool AjouterBanque(Banque banque, Inscrit inscrit);
bool SupprimerBanque(Banque banque, Inscrit inscrit);
IList<Banque> RecupererBanques(Inscrit inscrit);
IList<Banque> RecupererBanquesDisponible();
//actions sur les comptes
bool AjouterCompte(Compte compte, Inscrit inscrit);
bool SupprimerCompte(Compte compte, Inscrit inscrit);
IList<Compte> RecupererCompte(Banque banque, Inscrit inscrit);
//actions sur les Opérations
bool AjouterOperation(Compte compte, Operation operation);
bool SupprimerOperation(Compte compte, Operation operation);
IList<Operation> RecupererOperation(Compte compte);
//actions sur les Planifications
bool AjouterPlanification(Compte compte, Planification planification);
bool SupprimerPlanification(Compte compte, Planification planification);
IList<Planification> RecupererPlanification(Compte compte);
//actions sur les Echéances
bool AjouterEcheance(Compte compte, Echeance echeance);
bool SupprimerEcheance(Compte compte, Echeance echeance);
IList<Echeance> RecupererEcheance(Compte compte);
//actions utilitaire
bool TestConnexion();
}
}

@ -6,6 +6,7 @@ using System.Text.RegularExpressions;
using Model;
using System.Threading.Tasks;
using System.ComponentModel;
using Newtonsoft.Json;
namespace Model
{
@ -15,8 +16,9 @@ namespace Model
public event PropertyChangedEventHandler PropertyChanged;
public string Id { get; private set; }
public string Nom { get; private set; }
public int Id { get; set; }
public string Nom { get; set; }
public string Prenom { get; set; }
public string Mail
{
@ -36,7 +38,7 @@ namespace Model
}
private string mail;
public string Prenom { get; set; }
public string Mdp
{
@ -77,8 +79,10 @@ namespace Model
}
}
private List<Banque> lesBanques =new();
public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal = 0)
private List<Banque> lesBanques;
[JsonConstructor]
public Inscrit(int id, string nom, string mail, string prenom, string mdp, double soldeTotal = 0)
{
Id = id;
Nom = nom;
@ -88,25 +92,17 @@ namespace Model
SoldeTotal = soldeTotal;
lesBanques = new();
}
public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal, List<Banque> lesbanques)
public Inscrit(int id, string nom, string mail, string prenom, string mdp, double soldeTotal, List<Banque> lesbanques)
: this(id, nom, mail, prenom, mdp, soldeTotal)
{
LesBanques = lesbanques;
}
public Inscrit(string mail, string id)
{
Prenom = "Lucas";
Mail = mail;
Id = id;
}
public Inscrit(List<Banque> lesbanques)
{
LesBanques = lesbanques;
}
public void ajouterBanque(Banque banque)
{
LesBanques.Add(banque);
@ -123,5 +119,9 @@ namespace Model
Dev = devise;
}
public override string ToString()
{
return Id + " " + Nom + " " + Prenom + " " + Mail + " " + Mdp;
}
}
}

@ -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);
}
}
}

@ -12,6 +12,7 @@ namespace Model
Cb,
Esp,
Chq,
Vir
Vir,
Pre
}
}

@ -17,4 +17,8 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>
</Project>

@ -12,4 +12,8 @@
<None Remove="Platforms\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>
</Project>

@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
@ -32,20 +33,27 @@ namespace Model
public bool IsDebit { get; private set; }
public Operation(string intituleOperation, double montant, DateTime dateOperation, MethodePayement modePayement, bool isDebit=true)
public TagOperation Tag { get; private set; }
public bool FromBanque { get; private set; }
[JsonConstructor]
public Operation(string intituleOperation, double montant, DateTime dateOperation, MethodePayement modePayement, TagOperation tag, bool fromBanque, bool isDebit=true)
{
IntituleOperation = intituleOperation;
Montant = montant;
DateOperation = dateOperation;
ModePayement = modePayement;
IsDebit = isDebit;
Tag = tag;
FromBanque = fromBanque;
}
void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public override string ToString()
{
return IntituleOperation + " " + DateOperation + " " + Montant + " " + ModePayement + " " + IsDebit + "\n";
return IntituleOperation + " " + DateOperation + " " + Montant + " " + ModePayement + " " + IsDebit + " " + FromBanque + " " + Tag;
}
}
}

@ -1,5 +1,8 @@
using System;
using Microsoft.Maui.Controls;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -8,5 +11,32 @@ namespace Model
{
public class Planification
{
public string IntituleOperation { get; private set; }
public double Montant { get; private set; }
public DateTime DateOperation { get; private set; }
public MethodePayement ModePayement { get; private set; }
public bool IsDebit { get; private set; }
public TagOperation Tag { get; private set; }
[JsonConstructor]
public Planification(string intituleOperation, double montant, DateTime dateOperation, MethodePayement modePayement, TagOperation tag, bool isDebit = true)
{
IntituleOperation = intituleOperation;
Montant = montant;
DateOperation = dateOperation;
ModePayement = modePayement;
IsDebit = isDebit;
Tag = tag;
}
public override string ToString()
{
return IntituleOperation + " " + DateOperation + " " + Montant + " " + ModePayement + " " + IsDebit + " " + Tag;
}
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public enum TagOperation
{
None,
Alimentaire,
Carburant,
Habitation,
Energie,
Telephonie,
Loisir,
Restauration,
Divers,
Transport,
Transaction,
Santé
}
}

@ -1,6 +1,13 @@
using Data;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net.Http.Headers;
using System.Security.Principal;
using System.Xml.Linq;
//test OFX
/*
Console.WriteLine("Test Deserializer OFX - simplifié");
IList<Compte> comptes= new List<Compte>();
@ -17,3 +24,225 @@ foreach (Compte compte in comptes)
Console.WriteLine("\t\t"+operation);
}
}
*/
//test APIClient
Console.WriteLine("Test ClientAPI");
Console.WriteLine("\n\nEtat API : " + ClientAPI.GetStateApi().GetAwaiter().GetResult());
Console.WriteLine("\n\n\n----Inscrits----\n");
IList<Inscrit> res = ClientAPI.GetInscritsAsync().GetAwaiter().GetResult();
foreach(Inscrit i in res)
{
Console.WriteLine(i);
}
Console.WriteLine("\n--------\n");
IList<Inscrit> inscrit = ClientAPI.GetInscritAsync("renaudtoutnu@gmail.com").GetAwaiter().GetResult();
foreach (Inscrit i in inscrit)
{
Console.WriteLine(i);
}
Console.WriteLine("\n----Modifs----\n");
bool r = ClientAPI.PutPasswordInscritAsync("lucasevard@gmail.com", "CeciEstUnNouveauMdp123456789!").GetAwaiter().GetResult();
Console.WriteLine("Changement de mdp : "+r+"\n");
bool rr = ClientAPI.PostAddInscritAsync("LIVET", "Hugo", "livet.hugo2003@gmail.com", "EnAvantOuiOui!0").GetAwaiter().GetResult();
Console.WriteLine("Ajout user : " + rr + "\n");
Console.WriteLine("\n----Resultats----\n");
IList<Inscrit> modif = ClientAPI.GetInscritsAsync().GetAwaiter().GetResult();
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 : " + rrr + "\n");
modif = ClientAPI.GetInscritsAsync().GetAwaiter().GetResult();
foreach (Inscrit i in modif)
{
Console.WriteLine(i);
}
Console.WriteLine("\n\n\n----Banques----\n");
IList<Banque> banques = ClientAPI.GetBanquesAsync().GetAwaiter().GetResult();
foreach (Banque b in banques)
{
Console.WriteLine(b);
}
Console.WriteLine("\n--------\n");
IList<Banque> banquesId1 = ClientAPI.GetBanqueAsync("1").GetAwaiter().GetResult();
foreach (Banque b in banquesId1)
{
Console.WriteLine(b);
}
Console.WriteLine("\n----Modifs----\n");
bool rrrr = ClientAPI.PostAddBanqueInscritAsync("ORANGE BANK","1").GetAwaiter().GetResult();
Console.WriteLine("Add banque for user : " + rrrr + "\n");
Console.WriteLine("\n----Verif----\n");
banquesId1 = ClientAPI.GetBanqueAsync("1").GetAwaiter().GetResult();
foreach (Banque b in banquesId1)
{
Console.WriteLine(b);
}
Console.WriteLine("\n----Modifs----\n");
bool rrrrrr = ClientAPI.DeleteBanqueInscritAsync("ORANGE BANK", "1").GetAwaiter().GetResult();
Console.WriteLine("Del banque for user : " + rrrrrr + "\n");
Console.WriteLine("\n----Verif----\n");
banquesId1 = ClientAPI.GetBanqueAsync("1").GetAwaiter().GetResult();
foreach (Banque b in banquesId1)
{
Console.WriteLine(b);
}
Console.WriteLine("\n\n\n----Comptes----\n");
IList<Compte> comptes = ClientAPI.GetCompteAsync("1").GetAwaiter().GetResult();
foreach (Compte c in comptes)
{
Console.WriteLine(c);
}
Console.WriteLine("\n----Modifs----\n");
bool rrrrrrr = ClientAPI.PostAddCompteInscritAsync("PEL","1").GetAwaiter().GetResult();
Console.WriteLine("Add Compte for user : " + rrrrrrr + "\n");
Console.WriteLine("\n----Verif----\n");
comptes = ClientAPI.GetCompteAsync("1").GetAwaiter().GetResult();
foreach (Compte c in comptes)
{
Console.WriteLine(c);
}
rrrrrrr = ClientAPI.DeleteCompteInscritAsync("PEL", "1").GetAwaiter().GetResult();
Console.WriteLine("Del Compte for user : " + rrrrrrr + "\n");
Console.WriteLine("\n----Verif----\n");
comptes = ClientAPI.GetCompteAsync("1").GetAwaiter().GetResult();
foreach (Compte c in comptes)
{
Console.WriteLine(c);
}
Console.WriteLine("\n\n\n----Operations----\n");
IList<Operation> operations = ClientAPI.GetOperationAsync("1").GetAwaiter().GetResult();
foreach (Operation o in operations)
{
Console.WriteLine(o);
}
Console.WriteLine("\n----Modifs----\n");
rrrrrrr = ClientAPI.PostAddOperationInscritAsync(new Compte("1","PEL"), new Operation("test",100,DateTime.Now,MethodePayement.Cb, TagOperation.Alimentaire, true, true)).GetAwaiter().GetResult();
Console.WriteLine("Add Ope On Compte : " + rrrrrrr + "\n");
Console.WriteLine("\n----Verif----\n");
operations = ClientAPI.GetOperationAsync("1").GetAwaiter().GetResult();
foreach (Operation o in operations)
{
Console.WriteLine(o);
}
Console.WriteLine("\n----Modifs----\n");
rrrrrrr = ClientAPI.DeleteOperationInscritAsync("1", "test").GetAwaiter().GetResult();
Console.WriteLine("Del Ope On Compte : " + rrrrrrr + "\n");
Console.WriteLine("\n----Verif----\n");
operations = ClientAPI.GetOperationAsync("1").GetAwaiter().GetResult();
foreach (Operation o in operations)
{
Console.WriteLine(o);
}
Console.WriteLine("\n\n\n----Planifications----\n");
IList<Planification> planifications = ClientAPI.GetPlanificationAsync("1").GetAwaiter().GetResult();
foreach (Planification p in planifications)
{
Console.WriteLine(p);
}
Console.WriteLine("\n----Modifs----\n");
rrrrrrr = ClientAPI.PostAddPlanificationInscritAsync(new Compte("1", "PEL"), new Planification("test", 100, DateTime.Now, MethodePayement.Cb, TagOperation.Alimentaire, true)).GetAwaiter().GetResult();
Console.WriteLine("Add Pla On Compte : " + rrrrrrr + "\n");
Console.WriteLine("\n----Verif----\n");
planifications = ClientAPI.GetPlanificationAsync("1").GetAwaiter().GetResult();
foreach (Planification p in planifications)
{
Console.WriteLine(p);
}
Console.WriteLine("\n----Modifs----\n");
rrrrrrr = ClientAPI.DeletePlanificationInscritAsync("1", "test").GetAwaiter().GetResult();
Console.WriteLine("Del Pla On Compte : " + rrrrrrr + "\n");
Console.WriteLine("\n----Verif----\n");
planifications = ClientAPI.GetPlanificationAsync("1").GetAwaiter().GetResult();
foreach (Planification p in planifications)
{
Console.WriteLine(p);
}
Console.WriteLine("\n\n\n----Echeances----\n");
IList<Echeance> echeances = ClientAPI.GetEcheanceAsync("1").GetAwaiter().GetResult();
foreach (Echeance e in echeances)
{
Console.WriteLine(e);
}
Console.WriteLine("\n----Modifs----\n");
rrrrrrr = ClientAPI.PostAddEcheanceInscritAsync(new Compte("1", "PEL"), new Echeance("test", 100, DateTime.Now, MethodePayement.Cb, TagOperation.Alimentaire, true)).GetAwaiter().GetResult();
Console.WriteLine("Add Ech On Compte : " + rrrrrrr + "\n");
Console.WriteLine("\n----Verif----\n");
echeances = ClientAPI.GetEcheanceAsync("1").GetAwaiter().GetResult();
foreach (Echeance e in echeances)
{
Console.WriteLine(e);
}
Console.WriteLine("\n----Modifs----\n");
rrrrrrr = ClientAPI.DeleteEcheanceInscritAsync("1", "test").GetAwaiter().GetResult();
Console.WriteLine("Del Ech On Compte : " + rrrrrrr + "\n");
Console.WriteLine("\n----Verif----\n");
echeances = ClientAPI.GetEcheanceAsync("1").GetAwaiter().GetResult();
foreach (Echeance e in echeances)
{
Console.WriteLine(e);
}

@ -7,6 +7,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Data\Data.csproj" />
<ProjectReference Include="..\Modele\Model.csproj" />

@ -7,6 +7,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Data\Data_CI.csproj" />
<ProjectReference Include="..\Modele\Model_CI.csproj" />

@ -25,7 +25,7 @@ namespace TestsUnitaires
public void TestConstructeurCompte2()
{
List<Operation> testlistope = new();
Operation testope = new("test", 20, DateTime.Now, MethodePayement.Cb);
Operation testope = new("test", 20, DateTime.Now, MethodePayement.Cb, TagOperation.Alimentaire, true, true);
testlistope.Add(testope);
Compte c1 = new("012345678901", "Livret A", 234,testlistope);
Compte c2 = new("012345678902", "&e23R_te7", 1245.34, testlistope);
@ -48,7 +48,7 @@ namespace TestsUnitaires
public void testAjouterOperation()
{
Compte c1 = new("012345678901", "Livret A", 234);
c1.ajouterOperation(new("test", 20, DateTime.Now, MethodePayement.Cb));
c1.ajouterOperation(new("test", 20, DateTime.Now, MethodePayement.Cb, TagOperation.Alimentaire, true, true));
Assert.True(c1.LesOpe.Count() == 1);
}
@ -56,7 +56,7 @@ namespace TestsUnitaires
public void testSupprimerOperation()
{
Compte c1 = new("012345678901", "Livret A", 234);
Operation testope = new("test", 20, DateTime.Now, MethodePayement.Cb);
Operation testope = new("test", 20, DateTime.Now, MethodePayement.Cb, TagOperation.Alimentaire, true, true);
c1.ajouterOperation(testope);
Assert.True(c1.LesOpe.Count() == 1);
c1.supprimerOperation(testope);
@ -68,7 +68,7 @@ namespace TestsUnitaires
public void testSupprimerBanque()
{
Banque bq = new Banque("Crédit Agricole", "https://creditagricole.fr", "https://yt3.ggpht.com/a/AGF-l7_mEfX2eQaGm8GefLOg5ZMRciNw-pESE3gUWg=s900-c-k-c0xffffffff-no-rj-mo");
Inscrit i1 = new Inscrit("A1001", "Smith", "smith@gmail.com", "luke", "test20000aA", 500);
Inscrit i1 = new Inscrit(1, "Smith", "smith@gmail.com", "luke", "test20000aA", 500);
Assert.NotNull(i1.LesBanques);
i1.ajouterBanque(bq);
Assert.Contains(bq, i1.LesBanques);

@ -12,9 +12,9 @@ namespace TestsUnitaires
[Fact]
public void testCtorInscrit()
{
Inscrit i = new Inscrit("I001", "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000);
Inscrit i = new Inscrit(1, "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000);
Assert.NotNull(i);
Assert.Equal("I001", i.Id);
Assert.Equal(1, i.Id);
Assert.Equal("LIVET", i.Nom);
Assert.Equal("Hugo.LIVET@etu.uca.fr", i.Mail);
Assert.Equal("Hugo", i.Prenom);
@ -28,9 +28,9 @@ namespace TestsUnitaires
List<Banque> lesBanques = new List<Banque>();
Banque b = new Banque("CA", "enavantouioui.fr", "NaN.fr");
lesBanques.Add(b);
Inscrit i = new Inscrit("I001", "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000, lesBanques);
Inscrit i = new Inscrit(1, "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000, lesBanques);
Assert.NotNull(i);
Assert.Equal("I001", i.Id);
Assert.Equal(1, i.Id);
Assert.Equal("LIVET", i.Nom);
Assert.Equal("Hugo.LIVET@etu.uca.fr", i.Mail);
Assert.Equal("Hugo", i.Prenom);
@ -45,7 +45,7 @@ namespace TestsUnitaires
public void testAjoutBanqueInscrit()
{
Banque b = new Banque("CA", "enavantouioui.fr", "NaN.fr");
Inscrit i = new Inscrit("I001", "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000);
Inscrit i = new Inscrit(1, "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000);
i.ajouterBanque(b);
Assert.Contains(b, i.LesBanques);
}
@ -54,7 +54,7 @@ namespace TestsUnitaires
public void testSupprimerBanqueInscrit()
{
Banque b = new Banque("CA", "enavantouioui.fr", "NaN.fr");
Inscrit i = new Inscrit("I001", "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000);
Inscrit i = new Inscrit(1, "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000);
i.ajouterBanque(b);
i.SupprimerBanque(b);
Assert.DoesNotContain(b, i.LesBanques);
@ -66,17 +66,17 @@ namespace TestsUnitaires
[Fact]
public void testChoixDeviseInscrit()
{
Inscrit i = new Inscrit("I001", "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000);
Inscrit i = new Inscrit(1, "LIVET", "Hugo.LIVET@etu.uca.fr", "Hugo", "Tu Sauras Passss:)1215", 2000);
i.ChoisirDevise(Devises.Euro);
Assert.Equal(Devises.Euro, i.Dev);
}
[Theory]
[InlineData("I000001", "LIVET", "a@a.fr", "Hugo", "123Soleil@azerty", 20000, true)]//OK
[InlineData("I000002", "LIVET", "aa.fr", "Hugo", "123Soleil@azerty", 20000, false)]//Mail invalide psk pas de @
[InlineData("I000003", "LIVET", "a@a.fr", "Hugo", "123soleil@azerty", 20000, false)]//mdp Invalide psk mdp sans Maj
[InlineData("I000004", "LIVET", "a@a.fr", "Hugo", "Soleil@azerty", 20000, false)]//mdp Invalide psk pas de chiffres
public void CtorInscrit2TU(string id, string nom, string mail, string prenom, string mdp, double solde, bool notShouldThrowException)
[InlineData(1, "LIVET", "a@a.fr", "Hugo", "123Soleil@azerty", 20000, true)]//OK
[InlineData(2, "LIVET", "aa.fr", "Hugo", "123Soleil@azerty", 20000, false)]//Mail invalide psk pas de @
[InlineData(3, "LIVET", "a@a.fr", "Hugo", "123soleil@azerty", 20000, false)]//mdp Invalide psk mdp sans Maj
[InlineData(4, "LIVET", "a@a.fr", "Hugo", "Soleil@azerty", 20000, false)]//mdp Invalide psk pas de chiffres
public void CtorInscrit2TU(int id, string nom, string mail, string prenom, string mdp, double solde, bool notShouldThrowException)
{
if (!notShouldThrowException)
{

@ -1,4 +1,5 @@
using LinqToPgSQL;
using Data;
using LinqToPgSQL;
using Model;
using System;
using System.Collections.Generic;
@ -13,7 +14,7 @@ namespace TestsUnitaires
[Fact]
public void testLoadInscrit()
{
Manager m = new Manager(new PersLinqToPgSQL());
Manager m = new Manager(new PersAPI());
//Assert.Null(m.SelectedBanque);
//m.LoadInscrit("lucasevard@gmail.com", "test");
//Assert.Equal(m.SelectedInscrits, "00001");

@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Loading…
Cancel
Save