Beispiel #1
0
        public async Task SavePage([FromBody] DocumentSavePageInput input)
        {
            var userId   = _jwtReader.GetUserId();
            var document = await _documentRepository
                           .FirstOrDefaultAsync(d => d.Id == input.EditorDocumentId && d.UserId == userId);

            if (document == null)
            {
                return;
            }
            var pageInDocument = await _pageRepository
                                 .FirstOrDefaultAsync(p => p.EditorDocumentId == input.EditorDocumentId &&
                                                      p.PageNumber == input.PageNumber);

            if (input.PageNumber == 1 && !string.IsNullOrEmpty(input.PageThumbnail))
            {
                document.Image = input.PageThumbnail;
                _documentRepository.Update(document);
            }

            if (pageInDocument == null)
            {
                var pageToAdd = _mapper.Map <EditorDocumentPage>(input);
                pageToAdd.PreviewImage = input.PageThumbnail;
                await _pageRepository.AddAsync(pageToAdd);

                await _context.SaveChangesAsync();
            }
            else
            {
                pageInDocument.PreviewImage = input.PageThumbnail;
                pageInDocument.PageData     = Encoding.UTF8.GetBytes(input.PageData);
                _pageRepository.Update(pageInDocument);
                await _context.SaveChangesAsync();
            }
        }
Beispiel #2
0
        public async Task Like([FromBody] LikeDislikeInput input)
        {
            var hasLike = await HasLike(input);

            if (hasLike)
            {
                return;
            }
            var hasDislike = await HasDislike(input);

            if (hasDislike)
            {
                await RemoveDislike(input);
            }

            await _likeRepository.AddAsync(new EditorInteractionLike
            {
                UserId         = _jwtReader.GetUserId(),
                ObjectId       = input.ObjectId,
                ObjectTypeEnum = input.ObjectTypeEnum
            });

            await _context.SaveChangesAsync();
        }
Beispiel #3
0
 public async Task <int> GetFollowersNumber()
 {
     return(await GetFollowersNumber(_jwtReader.GetUserId()));
 }