Esempio n. 1
0
        public ArticleModel Select(ArticleCondition articleCondition = null)
        {
            Article   article   = _articleRepository.Select(articleCondition);
            UserModel userModel = _userService.SelectUser(article.Author);
            string    content   = article.Content;

            if (content.Contains(ConstantKey.NGINX_FILE_ROUTE_OLD))
            {
                content = content.Replace(ConstantKey.NGINX_FILE_ROUTE_OLD, ConstantKey.NGINX_FILE_ROUTE);
            }
            ArticleModel articleModel = new ArticleModel()
            {
                Id            = article.Id,
                Title         = article.Title,
                ArticleType   = article.ArticleType.GetEnumText(),
                CreateTime    = article.CreateTime.Value.ToString("yyyy/MM/dd"),
                Content       = content,
                Author        = userModel.Username,
                AuthorAccount = userModel.Account,
                IsDraft       = article.IsDraft ? "是" : "否",
                Comments      = CommentModel.ConvertToCommentModels(article.Comments)
            };
            BrowserCommand browserCommand = new BrowserCommand(article.Id);

            _eventBus.Publish(browserCommand);
            return(articleModel);
        }
Esempio n. 2
0
        private IList <WhisperModel> ConvertToModel(IEnumerable <Whisper> whispers)
        {
            IList <WhisperModel> whisperModels = new List <WhisperModel>();

            foreach (var item in whispers)
            {
                WhisperModel model = new WhisperModel();
                model.Id          = item.Id.ToString();
                model.Account     = item.Account;
                model.AccountName = item.AccountName;
                model.Content     = item.Content;
                model.CreateDate  = item.CreateTime.Value.ToString("yyyy-MM-dd hh:mm");
                if (item.CommentList != null)
                {
                    IEnumerable <CommentModel> commentDataModels = CommentModel.ConvertToCommentModels(item.CommentList);
                    model.Commentdatas = commentDataModels.ToList();
                }
                whisperModels.Add(model);
            }
            return(whisperModels);
        }
Esempio n. 3
0
        public IList <CommentModel> SelectCommnetsByWhisper(int whisperId)
        {
            IList <Comment> comments = _whisperRepository.SelectCommnetsByWhisper(whisperId);

            return(CommentModel.ConvertToCommentModels(comments));
        }