Exemple #1
0
        public async Task <bool> EditBodyAsync(ChapterEditRequest chapterRequest, string GetUserId, Guid TopicsId, Guid chapterId)
        {
            var topicOwn = await _context.Chapters
                           .Include(b => b.Topics)
                           .ThenInclude(x => x.Invitees)
                           .AnyAsync(s => (
                                         s.Topics.Invitees.Any(r => r.AppUserId.Equals(GetUserId) && r.RequestStatus.Equals(true)) ||
                                         s.Topics.AppUserId.Equals(GetUserId)
                                         ) &&
                                     s.Topics.Id.Equals(TopicsId));

            if (!topicOwn)
            {
                return(false);
            }

            var chapter = await GetChapterBodyIdAsync(GetUserId, chapterId, TopicsId);

            if (chapter == null)
            {
                return(false);
            }

            chapter.Body = chapterRequest.Body;

            chapter.CreatedDate = DateTime.Now;

            _context.Chapters.Update(chapter);

            var created = await _context.SaveChangesAsync();

            return(created > 0);
        }
Exemple #2
0
        public async Task <IActionResult> UpdateBody([FromBody] ChapterEditRequest chapterRequest, [FromRoute] Guid topicsId,
                                                     [FromRoute] Guid chatperId)
        {
            var chapter = await _editBodyService.EditBodyAsync(chapterRequest, GetUserId(), topicsId, chatperId);

            if (!chapter)
            {
                return(Ok(new AuthResponse
                {
                    Error = "The Name Already Exist"
                }));
            }

            return(Ok(new AuthResponse
            {
                Token = "The Chapter Body is Updated"
            }));
        }
        public async Task <AuthResponse> UpdateBodyAsync(Guid topicId, Guid chapterId, ChapterEditRequest chapterRequest)
        {
            var response = await _httpService.Post <ChapterEditRequest, AuthResponse>($"{topics}/{topicId}/{chapter}/{chapterId}", chapterRequest);

            if (!response.Success)
            {
                throw new ApplicationException(await response.GetBody());
            }

            return(response.Response);
        }