Ejemplo n.º 1
0
        public async Task Delete(string commentId, string userId)
        {
            Comment registeredComment;

            string commentRegisteredOnCacheJson = await _cacheDatabase.Get(commentId);

            if (commentRegisteredOnCacheJson != null)
            {
                registeredComment = _jsonUtils.Deserialize <Comment>(commentRegisteredOnCacheJson);
            }
            else
            {
                registeredComment = await _commentRepository.GetById(Guid.Parse(commentId));

                if (registeredComment == null)
                {
                    throw new ResourceNotFoundException("comment not found.");
                }
            }

            ThrowIfAuthenticatedUserNotIsCommentCreator(registeredComment, Guid.Parse(userId));

            _commentRepository.Delete(registeredComment);
            await _commentRepository.Save();

            await _cacheDatabase.Remove(commentId);
        }
Ejemplo n.º 2
0
        public async Task Delete(string userId, string reviewId)
        {
            Review review = await _reviewRepository.GetById(Guid.Parse(reviewId));

            if (review == null)
            {
                throw new ResourceNotFoundException("review not found.");
            }
            ThrowIfAuthenticatedUserNotBeReviewCreator(review, Guid.Parse(userId));
            _reviewRepository.Delete(review);
            await _reviewRepository.Save();

            await _cacheDatabase.Remove(review.Id.ToString());
        }
Ejemplo n.º 3
0
 public void RemoveUser(string connectionId)
 {
     _cacheDatabase.Remove(USER_KEY + connectionId);
 }