Esempio n. 1
0
        public void Comment(string statusId, string cmtMessage)
        {
            this.Init();
            var commentId = SequentialGuid.Create();
            var comment   = new DemoSignalRChat.Models.Comment
            {
                CommentId   = commentId,
                Content     = cmtMessage,
                StatusId    = statusId,
                UserId      = this._curUserChat.UserId,
                TimeComment = DateTime.Now
            };

            this._commentRepository.AddComment(comment);

            var      newFeedId = SequentialGuid.Create();
            NewFeeds newfeed   = new NewFeeds
            {
                UserId             = this._curUserChat.UserId,
                NewFeedId          = newFeedId,
                TypeActionId       = TypeAction.COMMENT,
                StatusId_Or_UserId = commentId
            };

            this._newFeedRepository.AddNewFeed(newfeed);


            string commentDisplay = ProcessComment.ProcessNewComment(this._curUserChat, cmtMessage);

            Clients.Clients(this._allUserRelate_ConnectionId).comment(this._curUserChat.Displayname, statusId, commentDisplay);
        }
        public StatusViewModel GetStatusViewModelByStatusId(string statusId)
        {
            Status status = this.GetStatusByStatusId(statusId);
            IStatusLocationRepository sttLocation          = new StatusLocationRepository(this._db);
            IStatusMessageRepository  sttMessageRepository = new StatusMessageRepository(this._db);
            IStatusImageRepository    sttImageRepository   = new StatusImageRepository(this._db);
            IUserRepository           userRepository       = new UserRepository(this._db);
            ILikeRepository           likeRepository       = new LikeRepository(this._db);
            IShareRepository          shareRepository      = new ShareRepository(this._db);
            ICommentRepository        commentRepository    = new CommentRepository(this._db);

            var message          = sttMessageRepository.GetMessageByStatusId(statusId);
            var messageProcessed = ProcessComment.ProcessMessage(message);

            LinkPreview linkPreview = ProcessMessage.GetFirstLinkPreview(message);

            var userOwner = userRepository.GetUserById(status.UserId);

            var statusViewModel = new
                                  StatusViewModel
            {
                StatusId      = statusId,
                TimePost      = status.TimePost,
                Location      = sttLocation.GetLocationForStatus(statusId),
                Message       = messageProcessed,
                Images        = sttImageRepository.GetListImage(statusId),
                UserOwner     = userOwner,
                LinkPreview   = linkPreview,
                NumShared     = shareRepository.GetNumShare(statusId),
                ListUserLiked = likeRepository.GetListUserLiked(statusId)
            };

            return(statusViewModel);
        }
        public CommentViewModel GetCommentByCommentId(string commentId)
        {
            var             comment        = this._db.Comments.ToList().Find(cmt => cmt.CommentId == commentId);
            IUserRepository userRepository = new UserRepository(this._db);
            var             userOwner      = userRepository.GetUserById(comment.UserId);

            ILikeCommentRepositoty likeCommentRepository = new LikeCommentRepository(this._db);
            var listUserLiked = likeCommentRepository.GetListUserLikedComment(commentId);

            return
                (new CommentViewModel
            {
                CommentId = comment.CommentId,
                TimeCommented = comment.TimeComment,
                Content = ProcessComment.ProcessMessage(comment.Content),
                UserOwner = userOwner,
                ListUserLiked = listUserLiked
            });
        }
        public StatusViewModel GetShortStatusByStatusId(string statusId)
        {
            Status status = this.GetStatusByStatusId(statusId);
            IStatusMessageRepository sttMessageRepository = new StatusMessageRepository(this._db);

            IUserRepository userRepository = new UserRepository(this._db);

            var message          = sttMessageRepository.GetMessageByStatusId(statusId);
            var messageProcessed = ProcessComment.ProcessMessage(message);

            var userOwner = userRepository.GetUserById(status.UserId);

            var statusViewModel = new
                                  StatusViewModel
            {
                StatusId  = statusId,
                TimePost  = status.TimePost,
                Message   = messageProcessed,
                UserOwner = userOwner
            };

            return(statusViewModel);
        }
Esempio n. 5
0
 internal void RaiseProcessComment(object sender, CommentEventArgs e) => ProcessComment?.Invoke(sender, e);