Exemple #1
0
        public async Task RemoveLikeFeed(ApplicationUser user, Guid refId, int likeType)
        {
            if (likeType != 1 && likeType != 2)
            {
                throw new BusinessException("WrongLikeType", "Yanlış beğenme tipi.");
            }

            var like = await _feedRepository.GetLikeAsync(refId, user.Id, likeType);

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

            _feedRepository.RemoveLike(like);
            if (likeType == 1)
            {
                await _feedRepository.ChangeLikeCountAsync(refId, -1);
            }
            else
            {
                await _feedRepository.ChangeDislikeCountAsync(refId, -1);
            }

            await _unitOfWork.CompleteAsync();
        }