parent
01cb8d35eb
commit
1d5cc3e009
@ -0,0 +1,30 @@
|
|||||||
|
package fr.iut.sciencequest.model.dto.extensions
|
||||||
|
|
||||||
|
import fr.iut.sciencequest.model.dto.question.QuestionDTO
|
||||||
|
import fr.iut.sciencequest.model.dto.question.QuestionWithSimpleResponseDTO
|
||||||
|
import fr.iut.sciencequest.model.metier.question.Question
|
||||||
|
import fr.iut.sciencequest.model.metier.question.QuestionWithSimpleReponse
|
||||||
|
|
||||||
|
fun QuestionDTO.ToModel(): Question {
|
||||||
|
return Question(
|
||||||
|
this.id,
|
||||||
|
this.question,
|
||||||
|
this.reponses.ToModel()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun List<QuestionDTO>.ToModel(): List<Question> {
|
||||||
|
val liste = mutableListOf<Question>()
|
||||||
|
for (question in this) {
|
||||||
|
liste.add(question.ToModel())
|
||||||
|
}
|
||||||
|
return liste
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Question.ToQuestionWithSimpleReponse(): QuestionWithSimpleReponse {
|
||||||
|
return QuestionWithSimpleReponse(
|
||||||
|
this.id,
|
||||||
|
this.question,
|
||||||
|
this.reponses.ToSimpleReponses()
|
||||||
|
)
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package fr.iut.sciencequest.model.dto.extensions
|
||||||
|
|
||||||
|
import fr.iut.sciencequest.model.dto.question.QuestionWithSimpleResponseDTO
|
||||||
|
import fr.iut.sciencequest.model.metier.question.QuestionWithSimpleReponse
|
||||||
|
|
||||||
|
fun QuestionWithSimpleResponseDTO.ToModel(): QuestionWithSimpleReponse {
|
||||||
|
return QuestionWithSimpleReponse(
|
||||||
|
this.id,
|
||||||
|
this.question,
|
||||||
|
this.reponses.ToModel()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun List<QuestionWithSimpleResponseDTO>.ToModel(): List<QuestionWithSimpleReponse> {
|
||||||
|
val liste = ArrayList<QuestionWithSimpleReponse>()
|
||||||
|
for (question in this) {
|
||||||
|
liste.add(question.ToModel())
|
||||||
|
}
|
||||||
|
return liste
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package fr.iut.sciencequest.model.dto.extensions
|
||||||
|
|
||||||
|
import fr.iut.sciencequest.model.dto.reponse.ReponseDTO
|
||||||
|
import fr.iut.sciencequest.model.metier.reponse.Reponse
|
||||||
|
import fr.iut.sciencequest.model.metier.reponse.ReponseSimple
|
||||||
|
|
||||||
|
fun ReponseDTO.ToModel(): Reponse {
|
||||||
|
return Reponse(
|
||||||
|
this.id,
|
||||||
|
this.reponse,
|
||||||
|
this.question.ToModel(),
|
||||||
|
this.scientifique.ToModel()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun List<ReponseDTO>.ToModel(): List<Reponse> {
|
||||||
|
val liste = ArrayList<Reponse>()
|
||||||
|
for (reponse in this) {
|
||||||
|
liste.add(reponse.ToModel())
|
||||||
|
}
|
||||||
|
return liste
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Reponse.ToSimpleReponse(): ReponseSimple {
|
||||||
|
return ReponseSimple(
|
||||||
|
this.id,
|
||||||
|
this.reponse
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun List<Reponse>.ToSimpleReponses(): List<ReponseSimple> {
|
||||||
|
val liste = ArrayList<ReponseSimple>()
|
||||||
|
for (reponse in this) {
|
||||||
|
liste.add(reponse.ToSimpleReponse())
|
||||||
|
}
|
||||||
|
return liste
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package fr.iut.sciencequest.model.dto.extensions
|
||||||
|
|
||||||
|
import fr.iut.sciencequest.model.dto.reponse.ReponseSimpleDTO
|
||||||
|
import fr.iut.sciencequest.model.metier.reponse.ReponseSimple
|
||||||
|
|
||||||
|
fun ReponseSimpleDTO.ToModel(): ReponseSimple {
|
||||||
|
return ReponseSimple(
|
||||||
|
this.id,
|
||||||
|
this.reponse
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun List<ReponseSimpleDTO>.ToModel(): List<ReponseSimple> {
|
||||||
|
val liste = ArrayList<ReponseSimple>()
|
||||||
|
for (reponse in this) {
|
||||||
|
liste.add(reponse.ToModel())
|
||||||
|
}
|
||||||
|
return liste
|
||||||
|
}
|
Loading…
Reference in new issue