示例#1
0
        public async Task RemoveComment(Guid commentId, string role, Guid userId)
        {
            var comment = await _feedRepository.GetCommentAsync(commentId);

            if (comment == null)
            {
                throw new BusinessException("CommentNotFound", "Kayıt bulunamadı.");
            }

            if (comment.User.Id != userId && role != Constants.RoleAdmin)
            {
                throw new BusinessException("NotAllowed", "Yetkiniz bulunmamaktadır.");
            }

            _feedRepository.RemoveComment(comment);
            await _feedRepository.ChangeCommentCountAsync(comment.RefId, -1);

            await _unitOfWork.CompleteAsync();
        }