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 void Add(LikeButtonModel model)
 {
     _likeButtonRepo.Add(model);
     _likeButtonRepo.SaveChange();
 }