fix: Fouten in implementatie van hello-mechanisme opgelost.

This commit is contained in:
Gerald Schmittinger 2025-04-19 16:47:47 +02:00
parent 59569445c3
commit 57ff2daf6c
5 changed files with 31 additions and 12 deletions

View file

@ -57,16 +57,22 @@ export async function getTeacher(username: string): Promise<TeacherDTO> {
return mapToTeacherDTO(user);
}
export async function createOrUpdateTeacher(userData: TeacherDTO, options?: { preventOverwrite?: boolean }): Promise<TeacherDTO> {
export async function createTeacher(userData: TeacherDTO): Promise<TeacherDTO> {
const teacherRepository: TeacherRepository = getTeacherRepository();
const newTeacher = mapToTeacher(userData);
await teacherRepository.save(newTeacher, { preventOverwrite: options?.preventOverwrite ?? true });
await teacherRepository.save(newTeacher);
return mapToTeacherDTO(newTeacher);
}
export async function createTeacher(userData: TeacherDTO): Promise<TeacherDTO> {
return await createOrUpdateTeacher(userData, { preventOverwrite: true });
export async function createOrUpdateTeacher(userData: TeacherDTO): Promise<TeacherDTO> {
await getTeacherRepository().upsert({
username: userData.username,
firstName: userData.firstName,
lastName: userData.lastName
});
return userData;
}
export async function deleteTeacher(username: string): Promise<TeacherDTO> {