コード例 #1
0
        public async Task CreateChapterQuestion(Guid currentMemberId, Guid chapterId, CreateChapterQuestion question)
        {
            await AssertMemberIsChapterAdmin(currentMemberId, chapterId);

            IReadOnlyCollection <ChapterQuestion> existing = await _chapterRepository.GetChapterQuestions(chapterId);

            int             displayOrder = existing.Count > 0 ? existing.Max(x => x.DisplayOrder) + 1 : 1;
            ChapterQuestion create       = new ChapterQuestion(Guid.Empty, chapterId, question.Name, question.Answer, displayOrder, 0);

            ValidateChapterQuestion(create);

            await _chapterRepository.CreateChapterQuestion(create);

            _cacheService.RemoveVersionedItem <ChapterQuestion>(chapterId);
        }
コード例 #2
0
        public async Task UpdateChapterQuestion(Guid currentMemberId, Guid questionId, CreateChapterQuestion question)
        {
            ChapterQuestion update = await GetChapterQuestion(currentMemberId, questionId);

            update.Answer = question.Answer;
            update.Name   = question.Name;

            ValidateChapterQuestion(update);

            await _chapterRepository.UpdateChapterQuestion(update);

            _cacheService.RemoveVersionedCollection <ChapterQuestion>(update.ChapterId);
        }