From 003eca2435e8efdccf6f6d53603cb9a6396d1843 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 27 Mar 2020 11:48:00 +0100 Subject: [PATCH] Delete all user responses to surveys --- src/helpers/AccountHelper.ts | 5 ++++- src/helpers/SurveyHelper.ts | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index 13d96cb..ecd0ff9 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -450,8 +450,11 @@ export class AccountHelper { // Delete all user posts await PostsHelper.DeleteAllUser(userID); + + // Delete all responses of user to surveys + await SurveyHelper.DeleteAllUserResponses(userID); */ - + // TODO : continue work } diff --git a/src/helpers/SurveyHelper.ts b/src/helpers/SurveyHelper.ts index 46b7d37..43870d7 100644 --- a/src/helpers/SurveyHelper.ts +++ b/src/helpers/SurveyHelper.ts @@ -232,6 +232,17 @@ export class SurveyHelper { })).map(this.DBTosurveyResponse) } + /** + * Delete all user responses to surveys + * + * @param userID Target user ID + */ + public static async DeleteAllUserResponses(userID: number) { + await DatabaseHelper.DeleteRows(SURVEY_RESPONSE_TABLE, { + ID_utilisateurs: userID + }); + } + /** * Turn a database entry into a survey object