Esempio n. 1
0
        public async Task <GetQuizByIdResults> ExecuteAsync(GetQuizByIdParameters parameters)
        {
            var quiz =
                await _quizRepository
                .GetByIdAsync(parameters.QuizId)
                .ConfigureAwait(false);

            var topic =
                await _topicsRepository
                .GetByIdAsync(quiz.TopicId)
                .ConfigureAwait(false);


            return(new GetQuizByIdResults(
                       id: quiz.Id,
                       name: quiz.Name,
                       creationTimestamp: quiz.CreationTimestamp,
                       userId: quiz.UserId,
                       questions: quiz.Questions,
                       topic: new TopicDetails(
                           id: topic.Id,
                           name: topic.Name,
                           imageUrl: topic.ImageUrl),
                       isPublic: quiz.IsPublic,
                       imageUrl: quiz.ImageUrl));
        }
Esempio n. 2
0
        public async Task <GetTopicByIdResults> ExecuteAsync(GetTopicByIdParameters parameters)
        {
            var topic = await _topicsRepository
                        .GetByIdAsync(parameters.TopicId)
                        .ConfigureAwait(false);

            return(new GetTopicByIdResults(
                       id: topic.Id,
                       name: topic.Name,
                       description: topic.Description,
                       imageUrl: topic.ImageUrl));
        }
Esempio n. 3
0
        public async Task <IActionResult> GetById(long id)
        {
            var topic = await _topicsRepository.GetByIdAsync(id);

            if (topic != null)
            {
                return(Ok(topic));
            }

            return(NotFound());
        }