@@ -8,48 +8,48 @@ import { Study } from "./study.entity";
88export class StudiesService {
99 constructor (
1010 @InjectRepository ( Study )
11- private readonly questionnaireRepository : EntityRepository < Study > ,
11+ private readonly studyRepository : EntityRepository < Study > ,
1212 private readonly em : EntityManager
1313 ) { }
1414
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 ) ;
1818
1919 try {
20- await this . em . persist ( questionnaire ) . flush ( ) ;
20+ await this . em . persist ( study ) . flush ( ) ;
2121 } catch ( e ) {
2222 if ( e instanceof UniqueConstraintViolationException ) {
2323 throw new UnprocessableEntityException ( "Study with this name already exists" ) ;
2424 }
2525 throw e ;
2626 }
2727
28- return questionnaire . toObject ( ) ;
28+ return study . toObject ( ) ;
2929 }
3030
3131 async findAll ( ) {
32- return ( await this . questionnaireRepository . findAll ( ) ) . map ( ( questionnaire ) => questionnaire . toObject ( ) ) ;
32+ return ( await this . studyRepository . findAll ( ) ) . map ( ( study ) => study . toObject ( ) ) ;
3333 }
3434
3535 async findOne ( id : number ) {
36- return ( await this . questionnaireRepository . findOneOrFail ( id ) ) . toObject ( ) ;
36+ return ( await this . studyRepository . findOneOrFail ( id ) ) . toObject ( ) ;
3737 }
3838
3939 async findBy ( filter : FilterQuery < Study > ) {
40- return ( await this . questionnaireRepository . findOneOrFail ( filter ) ) . toObject ( ) ;
40+ return ( await this . studyRepository . findOneOrFail ( filter ) ) . toObject ( ) ;
4141 }
4242
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 ) ;
4646
47- await this . em . persist ( questionnaire ) . flush ( ) ;
47+ await this . em . persist ( study ) . flush ( ) ;
4848
49- return questionnaire . toObject ( ) ;
49+ return study . toObject ( ) ;
5050 }
5151
5252 remove ( id : number ) {
53- return this . em . remove ( this . questionnaireRepository . getReference ( id ) ) . flush ( ) ;
53+ return this . em . remove ( this . studyRepository . getReference ( id ) ) . flush ( ) ;
5454 }
5555}
0 commit comments