Esempio n. 1
0
        public async Task <bool> DeleteUserDataAsync(string userId)
        {
            var settings = await _userSettingsRepository.GetById(userId);

            if (settings != null)
            {
                _userSettingsRepository.Delete(settings);
            }

            var accesses = _quizAccessesRepository.GetAllByUserId(userId);

            _quizAccessesRepository.DeleteRange(accesses);

            var solvedQuizzes = _solvedQuizRepository.GetAllByUserId(userId);

            _solvedQuizRepository.DeleteRange(solvedQuizzes);

            var learningQuizzes = _learningQuizzesRepository.GetAllByUserId(userId);

            _learningQuizzesRepository.DeleteRange(learningQuizzes);

            var quizzes = _quizzesRepository.GetAllByUserId(userId);

            _quizzesRepository.DeleteRange(quizzes);

            return(await Context.SaveChangesAsync() > 0);
        }
Esempio n. 2
0
        // Read methods

        public async Task <IEnumerable <Quiz> > GetUserQuizzesAsync(string userId)
        {
            var quizzes = await _quizzesRepository
                          .GetAllByUserId(userId)
                          .ToListAsync();

            await IncludeUserAccessAsync(quizzes, userId);

            var quizzesWithOwners = await _auth0UsersService.IncludeOwnerNickNames(quizzes);

            return(quizzesWithOwners);
        }