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); }
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()); }
public void RemoveUser(string connectionId) { _cacheDatabase.Remove(USER_KEY + connectionId); }