Ejemplo n.º 1
0
        public bool LikeComment(int commentId, string email)
        {
            try
            {
                var likeButton = _likeButtonRepo.GetSingleByCondition(x => x.CommentId == commentId && x.Email == email);
                if (likeButton == null)
                {
                    _likeButtonRepo.Add(new LikeButtonModel
                    {
                        CommentId = commentId,
                        Email     = email,
                        IsLike    = true
                    });
                }
                else
                {
                    likeButton.IsLike = !likeButton.IsLike;
                    _likeButtonRepo.Update(likeButton);
                }
                _likeButtonRepo.SaveChange();
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
 public LikeButtonModel GetByCommentIdAndUserId(int commentId, string userId)
 {
     return(_likeButtonRepo.GetSingleByCondition(x => x.CommentId == commentId && x.UserId == userId));
 }