Skip to content
Snippets Groups Projects
Commit d4747f0f authored by Hugo BAYOUD's avatar Hugo BAYOUD
Browse files

change logic in update comment

parent 6782ba08
No related branches found
No related tags found
No related merge requests found
......@@ -124,12 +124,11 @@ Paramètres `id`
# Documentation API SOAP
Le fichier WSDL associé se trouve dans `src/shared/ress`
Utiliser le logiciel SOAP UI pour obtenir toues les operations disponibles à partir du fichier WSDL.
Le fichier WSDL associé se trouve dans à la racine du projet.
Utiliser le logiciel `SOAP UI` pour obtenir toues les operations disponibles à partir du fichier WSDL.
Exemple avec la création d'un commentaire :
## Exemple avec la création d'un commentaire :
```
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:com="http://commentaires.cours.coffreo.com/">
<soapenv:Header/>
<soapenv:Body>
<com:create>
......@@ -146,12 +145,10 @@ Exemple avec la création d'un commentaire :
</arg0>
</com:create>
</soapenv:Body>
</soapenv:Envelope>
```
La réponse sera alors :
```
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:tns="http://commentaires.cours.coffreo.com/">
<soap:Body>
<tns:createResponse>
<auteur>Georges Orwell</auteur>
......@@ -160,13 +157,15 @@ La réponse sera alors :
<titre>Ceci est mon commentaire</titre>
</tns:createResponse>
</soap:Body>
</soap:Envelope>
```
* La date de création en entrée est de type Date et est ensuite passée en string.
Si une date invalide est passé en entrée, le commentaire sera créé mais contiendra
* La date de création en entrée est de type `Date` et est ensuite transformée en `string`.
Si une date invalide est passée en entrée, le commentaire sera créé mais contiendra la date actuelle au moment de la création
```
<dateCreation>Wed Dec 23 2020 15:23:56 GMT+0100 (GMT+01:00)</dateCreation>
```
* L'id a été généré à partir d'UUID car aucun id n'a été donné en entrée.
\ No newline at end of file
* L'id a été généré à partir d'un UUID car aucun id n'a été donné en entrée.
```
<id>3c4679e8-fed3-45f4-98ce-00583a0e5847</id>
```
\ No newline at end of file
......@@ -36,8 +36,7 @@ export class CommentaireService {
newComment.id = uuidv4();
}
newComment.dateCreation = newComment.dateCreation?.toString();
newComment.dateCreation = newComment.dateCreation?.toString() === "Invalid Date" ? (new Date()).toString() : newComment.dateCreation?.toString();
CommentaireService.commentaires = [...CommentaireService.commentaires, newComment];
return newComment;
......@@ -70,9 +69,21 @@ export class CommentaireService {
throw new NotFoundException();
}
let date: string;
if (comment.dateCreation === undefined) {
date = toUpdateComment.dateCreation;
} else {
if (comment.dateCreation.toString() === "Invalid Date") {
date = (new Date()).toString();
} else {
date = comment.dateCreation.toString();
}
}
const updatedComment: Commentaire = {
id: comment.id ? comment.id : toUpdateComment.id,
dateCreation: comment.dateCreation ? comment.dateCreation : toUpdateComment.dateCreation,
dateCreation: date,
auteur: comment.auteur ? comment.auteur : toUpdateComment.auteur,
titre: comment.titre ? comment.titre : toUpdateComment.titre,
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment