Ejemplo n.º 1
0
 private static void FillCommentUser(XElement element, CommentUser user)
 {
     FillAbstractUser(element, user);
     user.ID = element.GetXDecendentValue<int>("user_id");
     user.Url = element.GetXDecendentValue<string>("user_profile_url");
     user.Group = element.GetXDecendentValue<string>("user_group");
 }
Ejemplo n.º 2
0
        public CommentLikeReturnModel UnLikeComment(string currUserId, int commentId = -1)
        {
            CommentLikeReturnModel ret = new CommentLikeReturnModel();

            if (commentId == -1 || string.IsNullOrEmpty(currUserId))
            {
                ret.ErrorInformation.ErrorType       = ErrorType.NoAction;
                ret.ErrorInformation.UserInformation = "An Error Occured";
                return(ret);
            }
            else
            {
                CommentUser cl = _dbEntitySet.Where(p => p.UserInfoId == currUserId && p.CommentId == commentId && p.LikeStatus == LikeStatus.Like).FirstOrDefault();
                if (cl == null)
                {
                    ret.LikeStatus = LikeStatus.None;
                    ret.ErrorInformation.UserInformation = "Already not Liked";
                }
                // ITS OK
                else if (cl.LikeStatus == LikeStatus.Like)
                {
                    cl.LikeStatus = LikeStatus.None;
                    _dbEntitySet.Update(cl);
                    if (_context.SaveChanges() != 0)
                    {
                        ret.LikeStatus      = LikeStatus.None;
                        ret.IsActionSucceed = true;
                        return(ret);
                    }
                }
                else
                {
                    ret.LikeStatus = LikeStatus.None;
                    ret.ErrorInformation.UserInformation = "Comment Unliked";
                }
            }
            if (ret.IsActionSucceed)
            {
                int[] prevDislikedCache = _userLikeCacheService.GetUserDisikedCommentsIds(currUserId);
                if (prevDislikedCache != null)
                {
                    if (prevDislikedCache.Contains(commentId))
                    {
                        prevDislikedCache.Prepend(commentId);
                    }
                    _userLikeCacheService.SetUserDisikedCommentsIds(currUserId, prevDislikedCache, 30);
                }
                int[] prevlikedCache = _userLikeCacheService.GetUserLikedCommentsIds(currUserId);
                if (prevlikedCache != null)
                {
                    if (prevlikedCache.Contains(commentId))
                    {
                        prevlikedCache.Prepend(commentId);
                    }
                    _userLikeCacheService.SetUserLikedCommentsIds(currUserId, prevlikedCache, 30);
                }
            }
            return(ret);
        }
Ejemplo n.º 3
0
        public void CreateCommentUser(string userId, int commentId)
        {
            var commentUser = new CommentUser {
                UserId = userId, CommentId = commentId
            };

            commentUserRepository.Add(commentUser);
            SaveCommentUser();
        }
Ejemplo n.º 4
0
        public void CreateComment(Comment comment, string userId)
        {
            commentRepository.Add(comment);
            SaveComment();
            var commentUser = new CommentUser {
                UserId = userId, CommentId = comment.CommentId
            };

            commentUserRepository.Add(commentUser);
            SaveComment();
        }
Ejemplo n.º 5
0
        private static void FillCommentUserImage(XElement element, CommentUser u)
        {
            UserImage i = new UserImage();
            i.ImageSize = ImageSize.Small;
            i.Url = element.GetXDecendentValue<string>("small_user_avatar_image");
            u.Avatars.Add(i);

            i = new UserImage();
            i.ImageSize = ImageSize.Medium;
            i.Url = element.GetXDecendentValue<string>("medium_user_avatar_image");
            u.Avatars.Add(i);
        }