예제 #1
0
        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);
        }
예제 #2
0
        private FriendSugestViewModel GetFriendSugest(IEnumerable <string> friendListId, string friendIdSugest)
        {
            IUserRepository userRepository = new UserRepository(this._db);

            var friendSugest = userRepository.GetUserById(friendIdSugest);

            var friendIdsMutual  = GetListFriendMutualByUserID(friendListId, friendIdSugest);
            var listFriendMutual = userRepository.GetRangeUser(friendIdsMutual);

            return(new FriendSugestViewModel
            {
                UserId = friendSugest.UserId,
                Displayname = friendSugest.Displayname,
                Avatar = friendSugest.Avatar,
                ListFriendMutual = listFriendMutual
            });
        }
        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 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
            });
        }
예제 #5
0
        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);
        }
예제 #6
0
        private FriendSugestViewModel GetFriendSugest(IEnumerable<string> friendListId, string friendIdSugest)
        {
            IUserRepository userRepository = new UserRepository(this._db);

            var friendSugest = userRepository.GetUserById(friendIdSugest);

            var friendIdsMutual = GetListFriendMutualByUserID(friendListId, friendIdSugest);
            var listFriendMutual = userRepository.GetRangeUser(friendIdsMutual);
            return new FriendSugestViewModel
            {
                UserId = friendSugest.UserId,
                Displayname = friendSugest.Displayname,
                Avatar = friendSugest.Avatar,
                ListFriendMutual = listFriendMutual
            };
        }