@@ -8,48 +8,48 @@ import { Study } from "./study.entity";
8
8
export class StudiesService {
9
9
constructor (
10
10
@InjectRepository ( Study )
11
- private readonly questionnaireRepository : EntityRepository < Study > ,
11
+ private readonly studyRepository : EntityRepository < Study > ,
12
12
private readonly em : EntityManager
13
13
) { }
14
14
15
- async create ( questionnaireCreationDto : StudyCreationDto ) {
16
- const questionnaire = new Study ( ) ;
17
- questionnaire . assign ( questionnaireCreationDto ) ;
15
+ async create ( studyCreationDto : StudyCreationDto ) {
16
+ const study = new Study ( ) ;
17
+ study . assign ( studyCreationDto ) ;
18
18
19
19
try {
20
- await this . em . persist ( questionnaire ) . flush ( ) ;
20
+ await this . em . persist ( study ) . flush ( ) ;
21
21
} catch ( e ) {
22
22
if ( e instanceof UniqueConstraintViolationException ) {
23
23
throw new UnprocessableEntityException ( "Study with this name already exists" ) ;
24
24
}
25
25
throw e ;
26
26
}
27
27
28
- return questionnaire . toObject ( ) ;
28
+ return study . toObject ( ) ;
29
29
}
30
30
31
31
async findAll ( ) {
32
- return ( await this . questionnaireRepository . findAll ( ) ) . map ( ( questionnaire ) => questionnaire . toObject ( ) ) ;
32
+ return ( await this . studyRepository . findAll ( ) ) . map ( ( study ) => study . toObject ( ) ) ;
33
33
}
34
34
35
35
async findOne ( id : number ) {
36
- return ( await this . questionnaireRepository . findOneOrFail ( id ) ) . toObject ( ) ;
36
+ return ( await this . studyRepository . findOneOrFail ( id ) ) . toObject ( ) ;
37
37
}
38
38
39
39
async findBy ( filter : FilterQuery < Study > ) {
40
- return ( await this . questionnaireRepository . findOneOrFail ( filter ) ) . toObject ( ) ;
40
+ return ( await this . studyRepository . findOneOrFail ( filter ) ) . toObject ( ) ;
41
41
}
42
42
43
- async update ( id : number , questionnaireMutationDto : StudyMutationDto ) {
44
- const questionnaire = await this . questionnaireRepository . findOneOrFail ( id ) ;
45
- questionnaire . assign ( questionnaireMutationDto ) ;
43
+ async update ( id : number , studyMutationDto : StudyMutationDto ) {
44
+ const study = await this . studyRepository . findOneOrFail ( id ) ;
45
+ study . assign ( studyMutationDto ) ;
46
46
47
- await this . em . persist ( questionnaire ) . flush ( ) ;
47
+ await this . em . persist ( study ) . flush ( ) ;
48
48
49
- return questionnaire . toObject ( ) ;
49
+ return study . toObject ( ) ;
50
50
}
51
51
52
52
remove ( id : number ) {
53
- return this . em . remove ( this . questionnaireRepository . getReference ( id ) ) . flush ( ) ;
53
+ return this . em . remove ( this . studyRepository . getReference ( id ) ) . flush ( ) ;
54
54
}
55
55
}
0 commit comments