public async Task <IDictionary <QuizAccessEnum, IList <BasicUser> > > GetQuizUsersAsync(Guid quizId, string userId) { var access = await _quizzesRepository.HaveWriteAccessToQuiz(userId, quizId); if (!access) { return(null); } var quiz = await _quizzesRepository .GetAll() .Where(q => q.Id == quizId) .Include(q => q.Accesses) .SingleOrDefaultAsync(); return(quiz?.Accesses .Where(a => a.Access != QuizAccessEnum.None) .GroupBy(a => a.Access) .Select(async a => new KeyValuePair <QuizAccessEnum, IList <BasicUser> >( a.Key, (await _auth0UsersService.GetBasicUsersListByIds(a.Select(ac => ac.UserId).ToList())).ToList() )) .Select(a => a.Result) .ToDictionary(a => a.Key, a => a.Value)); }
private async Task <object> GetQuizStatistics(Guid quizId) { var quiz = await _quizzesRepository .GetAll() .Where(q => q.Id == quizId) .Include(q => q.Sessions) .SingleOrDefaultAsync(); return(new { Quiz = quiz, NumberOfLearnSessions = quiz.Sessions.NumberOfLearnSessions, NumberOfSolveSessions = quiz.Sessions.NumberOfSolveSessions, SolvingStatistics = await GetSolvingStatistics(quizId), LearningStatistics = await GetLearningStatistics(quizId) }); }