Exemplo n.º 1
0
        public static CommentModel MergeCommentViewWithModel(CommentModel model, ArticleCommentView view)
        {
            model.Content = view.Comment.Content;
            model.User    = view.Comment.User;
            //model.Email = view.Email;
            //model.Name = view.Name;

            return(model);
        }
        public async Task <IActionResult> Add(ArticleCommentView result)
        {
            var user = await _userManager.GetUserAsync(User);

            var articleId    = result.Article.Id;
            var commentModel = ArticleHelpers.ConvertCommentToModel(result, user);
            var comment      = await _commentService.Create(commentModel, articleId);

            return(RedirectToAction("Details", "Article", new { id = articleId }));
        }
Exemplo n.º 3
0
        public static ArticleModel MergeArticleViewWithModel(ArticleModel model, ArticleCommentView view)
        {
            model.Title         = view.Article.Title;
            model.Slug          = view.Article.Slug;
            model.Content       = view.Article.Content;
            model.CommentStatus = view.Article.CommentStatus;
            model.Abstract      = view.Article.Abstract;
            model.Literature    = view.Article.Literature;
            //model.IsDraft = view.IsDraft;
            //model.Excerpt = view.Excerpt;
            //model.FullUrl = BuildArticleFullUrl(mainUrl, view.Slug);

            return(model);
        }
Exemplo n.º 4
0
        public static CommentModel ConvertCommentToModel(ArticleCommentView result, User user)
        {
            var commentModel = new CommentModel
            {
                AddDate = DateTime.Now,
                Content = result.Comment.Content,
                User    = user,
                //Name = result.Name,
                //Email = result.Email,
                //ArticleId = article.Id
            };

            return(commentModel);
        }
Exemplo n.º 5
0
        public static ArticleCommentView ConvertToDetailsView(ArticleModel article)
        {
            var articleCommentView = new ArticleCommentView
            {
                Article = new ArticleView
                {
                    Id            = article.Id,
                    Title         = article.Title,
                    Content       = article.Content,
                    Abstract      = article.Abstract,
                    Literature    = article.Literature,
                    Views         = article.Views,
                    CommentStatus = article.CommentStatus,
                    Slug          = article.Slug,
                    User          = article.User,
                    FullUrl       = article.FullUrl,
                    AddDate       = article.AddDate.ToShortDateString()
                }

                //Comment = new CommentView
                //{
                //    Id = comment.Id,
                //    AddDate = DateTime.Now,
                //    Content = comment.Content,
                //    User = comment.User
                //}
            };

            if (article.Image == null)
            {
                articleCommentView.Article.ImageUrl = "https://res.cloudinary.com/dyytlulq9/image/upload/v1609687626/logo_dirysy.png";
            }
            else
            {
                articleCommentView.Article.ImageUrl = article.Image.Url;
            }

            return(articleCommentView);
        }
Exemplo n.º 6
0
        public static ArticleModel ConvertArticleToModel(ArticleCommentView result, User user)
        {
            var articleModel = new ArticleModel
            {
                //AddDate = MergeTimeWithDate(article.Date, article.Time),
                AddDate    = DateTime.Now,
                Content    = result.Article.Content,
                Title      = result.Article.Title,
                Abstract   = result.Article.Abstract,
                Literature = result.Article.Literature,
                //Excerpt = article.Excerpt,
                //IsDraft = article.IsDraft,
                CommentStatus = result.Article.CommentStatus,
                //Slug = ValidateSlug(article.Slug),
                ModifiedDate = null,
                //FullUrl = BuildArticleFullUrl(mainUrl, ValidateSlug(article.Slug)),
                //MenuOrder = null,
                CommentCount = 0,
                User         = user
            };

            return(articleModel);
        }